in reply to Re: Perl Project: Text Search
in thread Perl Project: Text Search
#!/usr/bin/perl $filename = '/etc/passwd.bak'; open(FILE, $filename) or die "Could not read from $filename, program h +alting."; while(<FILE>) { chomp; @fields = split(':', $_); if ($ARGV[0] eq $fields[0]){ print "Home directory: $fields[5]\n"; print "Shell used: $fields[6]\n"; exit 0; } elsif ($ARGV[0] != $fields[0]){ print "User: username does not exist.\n"; exit 0; } elsif ((@ARGV > 1) || (@ARGV == 0)){ print "Please enter at least one but only one argument.\n"; exit 0; } } close FILE;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Perl Project: Text Search
by crashtest (Curate) on Apr 09, 2010 at 00:10 UTC | |
by Anonymous Monk on Apr 09, 2010 at 12:48 UTC | |
by Sharp (Initiate) on Apr 09, 2010 at 03:04 UTC | |
Re^3: Perl Project: Text Search
by Sharp (Initiate) on Apr 08, 2010 at 21:02 UTC |