#!/usr/bin/perl $filename = '/etc/passwd.bak'; if ($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; } 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; } } close FILE;
In reply to Re^4: Perl Project: Text Search
by Anonymous Monk
in thread Perl Project: Text Search
by Sharp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |