Yeah my bad I was thinking of the example you showed rather than the one that appends.
Regarding:
map +{ "category_$_" => .....
and
map { +"category_$_" => ....
....the difference is that the first example creates an anonymous hashref whereas the second one doesn't.
For example in a script Im writing at the moment, in order to generate a template loop (arrayref of hashrefs) I use:
my $loop = [ map +{ tag => $_->[0] }, @$array_ref ];
If I left out the + I'd have an arrayref and with the + in the other place I'd get the same
Also note that with +{ you need the comma after the }
Regarding:
map +{ "category_$_" => .....
and
map { +"category_$_" => ....
....the difference is that the first example creates an anonymous hashref whereas the second one doesn't.
For example in a script Im writing at the moment, in order to generate a template loop (arrayref of hashrefs) I use:
Code:
my $array_ref = $something_from_mysql; my $loop = [ map +{ tag => $_->[0] }, @$array_ref ];
If I left out the + I'd have an arrayref and with the + in the other place I'd get the same
Also note that with +{ you need the comma after the }