There is an easier way to do what you want, using a CPAN module called Unix::PasswdFile:
use Unix::PasswdFile; my $pw = Unix::PasswdFile->new('/etc/passwd') or die 'Could not open /etc/passwd'; my %users = map { $_ => [$ps->user($_)] } $pw->users;
This will create the %users hash without you needing to worry about the structure of the /etc/passwd file.
In reply to (dkubb) Re: (2) Parsing the /etc/passwd file
by dkubb
in thread assigning to a hash via split
by aardvark
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |