Assigning anonymous hash to a list

Mark Stringer mark at repixl.com
Tue Jul 30 20:11:54 BST 2013


Not sure why it's inconsistent. This works as you'd expect. Note the parens.

my ($str, $ref) = ('text', {a => 1, b => 2, c => 3});

Mark

On 07/30/2013 07:54 PM, gvim wrote:
> Can anyone explain why this works:
>
> my $ref = {a => 1,  b => 2, c => 3};
> say $ref->{b};     #  Result: 2
>
> ... but this doesn't :
>
> my ($str, $ref) = 'text', {a => 1, b => 2, c => 3};
> say $ref->{b};   # Result: Use of uninitialized value
>
> Seems a little inconsistent.
>
> gvim



More information about the london.pm mailing list