Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: selecting values from hash via list (slice)

by toolic (Bishop)
on Nov 06, 2009 at 21:14 UTC ( [id://805585]=note: print w/replies, xml ) Need Help??


in reply to selecting values from hash via list

I'm confused. Your 2 printf statements print the same thing for me. Isn't that what you want -- to use a hash slice to save typing? See Slices.
printf "%-20s %5d %s\n", $h{name}, $h{age}, $h{zone}; printf "%-20s %5d %s\n", @h{qw/name age zone/};

Replies are listed 'Best First'.
Re^2: selecting values from hash via list (slice)
by leocharre (Priest) on Nov 06, 2009 at 22:23 UTC
    Oh.. dear... it works.. I thought I was making up code!

    I thought this was nonsense! : printf "%-20s %5d %s\n", @h{qw/name age zone/};

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found