Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

(dkubb) Re: (2) Parsing the /etc/passwd file

by dkubb (Deacon)
on Feb 19, 2001 at 07:24 UTC ( [id://59337]=note: print w/replies, xml ) Need Help??


in reply to assigning to a hash via split

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://59337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found