>>
Can someone explain why this makes a new hash and returns a reference to it:
sub hashem { +{ @_ } }
<<
A hash is just an associative array, ie the following will work as a hash but may look like an array to you:
my %hash = ( a, 1, b, 1, c ,1 );
$hash{a} prints 1 as does $hash{b} and $hash{c};
The { } references @_ which is essentially the same as
%hash = \%hash;
The + sign forces an anonymous hash contructor.
Can someone explain why this makes a new hash and returns a reference to it:
sub hashem { +{ @_ } }
<<
A hash is just an associative array, ie the following will work as a hash but may look like an array to you:
my %hash = ( a, 1, b, 1, c ,1 );
$hash{a} prints 1 as does $hash{b} and $hash{c};
The { } references @_ which is essentially the same as
%hash = \%hash;
The + sign forces an anonymous hash contructor.