Repository navigation
Expand file tree
/
Copy path7exec.pl
More file actions
executable file
·72 lines (61 loc) · 1.97 KB
/
Copy path7exec.pl
File metadata and controls
executable file
·72 lines (61 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl
# Quantifiers = '+'' - One or More.
# = '?' - Zero or One.
# = '*' - Zero or More.
# = '.*' - Matches the most characters possible before the next character.
use strict;
use warnings;
sub regex1 {
# ##Enter at least one a, followed by any number of b's
# print "Enter at least one a, followed by any number of b's\n";
# my $pattern = <>;
# if ($pattern =~ /^a+b*/) {
# print "Match Found\n";
# } else {
# print "Match Not Found\n";
# }
# Enter any number of backslashes followed by any number of asterisks.
# print "Enter any number of backslashes followed by any number of asterisks\n";
# my $pattern = <>;
# if ($pattern =~ /^\\*(\*)+$/) {
# # body...
# print "Pattern Found\n";
# } else {
# # else...
# print "Pattern not found\n";
# }
# Three consecutive copies of whatever is contained in $pattern
#print "Enter a pattern\n";
# my $pattern = "chait";
# print "$pattern\n" x 3;
#Match any 5 characters including newline.
# print "Enter any 5 characters including newline\n";
# my $pattern = <>;
# chomp $pattern;
# $pattern =~ /.|\n {5} /;
# print "$pattern";
#Look for a line containing a,e,i,o,u
# print "Enter alphabets with vowels in them\n";
# my $line = <>;
# chomp $line;
# #if ($line =~ /a*e*i*o*u/i) { #Vowels can be anywhere in the line
# #if ($line =~ /aeiou/i) { #Vowels have to be in order.
# if ($line =~ /[^eiou]*a[^iou]*e[^aou]*i[^aeu]*o[^aei]*u/i) {
# print "Contains all vowels in order\n";
# } else {
# # else...
# #print "Line doesn't contain all the Vowels\n";
# print "Vowels not in order\n";
# }
## reads /etc/passwd and print username and realname
my $filename = '/etc/passwd';
open (my $fh , '<:encoding(UTF-8)', $filename) or die "Cannot Open File: $filename\n";
while (my $row = <$fh>) {
chomp $row;
my ($user, $real) = (split /:/, $row) [0,4];
print "$user : $real\n";
#my @fields = split(/:+/, $row);
#print "User: $fields[0]" . "\t" . "RealName: $fields[4]" . "\n";
}
}
regex1;