Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Retunining hash values from subroutines

by kcott (Archbishop)
on Jun 20, 2013 at 21:21 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-25 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found