Guest_imported
New member
- Jan 1, 1970
- 0
WRite a Perl script named usernames.pl that looks through the /etc/passwd file for two (or more) users with the same first name, and prints those names.
Hint: after extracting the first name, create a hash with the name for a key and the number of times it was seen as the value. When teh last line of teh fale has been read, look through the hash for counts of greater than one.
This is what i have so far!
while (<WHO>) {
($login, $rest) = /^(\s+(.*)/;
$login = $real {$login} if $real{$login};
printf "%-30s %s\n" , $login, $rest;
}
Hint: after extracting the first name, create a hash with the name for a key and the number of times it was seen as the value. When teh last line of teh fale has been read, look through the hash for counts of greater than one.
This is what i have so far!
while (<WHO>) {
($login, $rest) = /^(\s+(.*)/;
$login = $real {$login} if $real{$login};
printf "%-30s %s\n" , $login, $rest;
}