in reply to How to print key and value of hash in a list
Some examples using the "babycart" (@{ [ ... ] }) operator to interpolate a bit of code into a double-quoted string.
knoppix@Microknoppix:~$ perl -E ' > %hash = ( a => 1, b => 2, c => 3 ); > say qq{@{ [ values %hash ] }}; > say qq{@{ [ sort { $b <=> $a } values %hash ] }}; > say qq{@{ [ map $hash{ $_ }, sort keys %hash ] }};' 3 1 2 3 2 1 1 2 3 knoppix@Microknoppix:~$
I hope this is helpful.
Cheers,
JohnGG
|
---|
In Section
Seekers of Perl Wisdom