The outer pair of curlies with the sigil dereferences the anonymous hash created by the inner pair, acting on the list returned by the block in the innermost pair, which is the argument to map. keys wants a hash.
Also, Edit: Also, you likened "array" to:
This is a scalar holding a reference to an anonymous array. An array is differentiated from a list by context, not by square versus round brackets.$VAR1 = [ 'one', 'fish', 'two', 'fish', 'red', 'fish', 'blue', 'fish' ];
But for your last question, if you want an array containing the flattened hash derived from your map and then want to dumper it to get the output you showed:
Because square brackets return a reference to what map returns, so Data::Dumper prints as one data structure.say Dumper( [ map { $_ => "fish" } qw(one two red blue) ] );
In reply to Re: Syntax for casting map to a hash or an array
by 1nickt
in thread Syntax for casting map to a hash or an array
by cbeckley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |