in reply to Hash value printing... WITH ARRAYS *dun dun dun*
use warnings; use strict; my $primaryFeatures = { 'foo', ['fool', 'food', 'foot'], 'bar', ['barricade'], }; while (my ($key, $value) = each(%$primaryFeatures)){ print "($key, $_)\n" for @{ $value }; } __END__ (bar, barricade) (foo, fool) (foo, food) (foo, foot)
I used square brackets to construct the arrays, then I dereferenced the arrays in the while loop.
It is also customary to use fat commas (=>) when constructing hashes
my $primaryFeatures = { foo => ['fool', 'food', 'foot'], bar => ['barricade'], };
|
|---|