in reply to Fetch array of values from hashref
Rule of thumb for Perl:
- Replace the symbol with the ref!
- Respect precedence
demo:
DB<1> @a = c..d DB<2> @h{a..d}=1..4 DB<3> $h_ref = \%h DB<4> x $h_ref # dump all 0 HASH(0x3531868) 'a' => 1 'b' => 2 'c' => 3 'd' => 4 DB<5> x @h{@a} 0 3 1 4 DB<6> x @{$h_ref}{@a} # play it safe 0 3 1 4 DB<7> x @$h_ref{@a} # brackets not needed b/c precedence already r +espected 0 3 1 4 DB<8>
HTH! :)
PS: Side note: "hashslice from hashref" is the technical term for "Fetch array of values from hashref"
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
---|