in reply to Re^4: Syntax for casting map to a hash or an array
in thread Syntax for casting map to a hash or an array
Yep, both of those work, however not for the same reason.
Dumper takes a reference of any type.
This:
{map { $_ => 'fish' } qw(one two red blue)}
... takes whatever is compiled by map, then with the outer braces, converts that into a hash reference, then returns the hash ref (same for the next one with an array). Putting the sigil in front of that block, and it will deref the created reference into a hash, and return it as a hash as opposed to a reference. For Dumper, you'd then need to dereference it before sending it in as a parameter.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Syntax for casting map to a hash or an array
by cbeckley (Curate) on Apr 05, 2017 at 18:50 UTC | |
by shmem (Chancellor) on Apr 05, 2017 at 19:07 UTC | |
by cbeckley (Curate) on Apr 05, 2017 at 19:14 UTC | |
by shmem (Chancellor) on Apr 05, 2017 at 19:28 UTC | |
by stevieb (Canon) on Apr 05, 2017 at 19:30 UTC |
In Section
Seekers of Perl Wisdom