Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Retunining hash values from subroutines

by kcott (Archbishop)
on Jun 20, 2013 at 21:21 UTC ( #1040030=note: print w/replies, xml ) Need Help??

in reply to Retunining hash values from subroutines

G'day Bindo,

You seem to have your answer with respect to "... main rational here is to understand hash behavior in subs.". This is additional information, regarding your example code, which you may find useful.

Here's a much more succinct way to generate the output you want:

$ perl -Mstrict -Mwarnings -le ' while (my @pwent = getpwent()) { next if $pwent[2] <= 500; print join " --> ", @pwent[0,7]; } ' ... ken --> /Users/ken ...

In addition to getpwent() (which iterates through all records), there's also getpwnam() (which returns a single record based on username), getpwuid() (which returns a single record based on numeric user ID) and other related functions.

While the online documentation (Fetching user and group info) lists these functions, it provides little in the way of details (return values are not even shown). For that, you can use:

perldoc -f getpwent

-- Ken

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2023-06-09 07:36 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (35 votes). Check out past polls.