Assigning anonymous hash to a list

Fahad Khan fahad.aj.khan at gmail.com
Tue Jul 30 20:11:12 BST 2013


ITYM,

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


extra () are needed.


On Tue, Jul 30, 2013 at 7:54 PM, gvim <gvimrc at gmail.com> 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