in reply to Fetch array of values from hashref
c:\@Work\Perl\monks>perl -wMstrict -MData::Dumper -le "my @a = qw/c b d/; ;; my %h = ( a => 4, b => 3, c => 2, d => 1, ); ;; my @b = @h{@a}; print \"2 3 1\n\", Dumper(\@b), \"\n\"; ;; my $hr = \%h; my @c = @{ $hr }{ @a }; print \"2 3 1\n\", Dumper(\@c), \"\n\"; " 2 3 1 $VAR1 = [ 2, 3, 1 ]; 2 3 1 $VAR1 = [ 2, 3, 1 ];
Update: Oops... Fixed example code: Was dumping @b twice!
Give a man a fish: <%-{-{-{-<
|
|---|