leocharre has asked for the wisdom of the Perl Monks concerning the following question:
I'm going to print some of this data with printf..my %h = ( name => 'dumdum', age => 14, zone => 'a4', pocket => 'empty', );
printf "%-20s %5d %s\n", $h{name}, $h{age}, $h{zone};
What's another way to specify those three values? Specifically, as you would as list args.. I know this has to be out there.
I like this trick to init hash keys (learned it here)..
Maybe there's some way to ...err... uhhhm ...my %a; my @a = qw/name age zone pocket/; @a{@a}=(); # looks weird, eh? ;-) # now 'exists $a{name}' is true!
???printf "%-20s %5d %s\n", @h{qw/name age zone/};
(sorry about the title, dunno how else the heck to word this)
update
Silly me, that second example, that was the solution, thanks toolic
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: selecting values from hash via list (slice)
by toolic (Bishop) on Nov 06, 2009 at 21:14 UTC | |
by leocharre (Priest) on Nov 06, 2009 at 22:23 UTC |