Assigning anonymous hash to a list
Hernan Lopes
hernanlopes at gmail.com
Wed Jul 31 03:36:12 BST 2013
sorry i meant 1 thing on the left and one thing on the right. Both are
lists and should be the same size.
On 7/30/13, Hernan Lopes <hernanlopes at gmail.com> wrote:
> When you do that, you are implicitly saying:
>
> The thing on the left is equals the thing in the right.
> So, in the left you have 1 thing ( a list because of parenthesis ),
> and on the right, you have 2 things: string+object.
>
> Add parenthesis on the right and transform it into a list.
>
> After that perl will understand you are assinging the first thing on
> the list (from left) equals the first thing on the list (from right)
> and so on.
>
> []'s
>
> Hernan Lopes
>
> On 7/30/13, 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