Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: assigning to a hash via split

by BlueLines (Hermit)
on Feb 19, 2001 at 07:19 UTC ( [id://59336]=note: print w/replies, xml ) Need Help??


in reply to assigning to a hash via split

You mayt also want to check out getpwent, which handles the iteration over the passwd(5) file and removes the need for the split (and open) in the first place.

BlueLines

Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.

Replies are listed 'Best First'.
Re: Re: assigning to a hash via split
by japhy (Canon) on Feb 19, 2001 at 08:11 UTC
    Ooh, good catch. You get a ++ from me, and I offer this in reply:
    sub buildUserHash { use User::pwent; my %users; while (my $obj = getpwent) { $users{$obj->name} = $obj } return \%users; }
    Now, you have a hash of User::pwent objects.

    japhy -- Perl and Regex Hacker

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-19 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found