Assigning anonymous hash to a list

Hernan Lopes hernanlopes at gmail.com
Wed Jul 31 17:04:11 BST 2013


it should be the same size to do what he wants... otherwise it wont work.


On 7/31/13, Abigail <abigail at abigail.be> wrote:
> On Tue, Jul 30, 2013 at 11:36:12PM -0300, Hernan Lopes wrote:
>> sorry i meant 1 thing on the left and one thing on the right. Both are
>> lists and should be the same size.
>
>
> Since when? Both:
>
>     my ($a, $b) = (1);
>
> and
>
>     my ($a, $b) = (1, 2, 3);
>
> are fine.
>
>> 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.
>
> As said before, adding parenthesis to the RHS of the assignment doesn't
> turn that into a list. The RHS is already a list, due to the fact it's
> in list context, which in turn is caused by the list of the LHS.
>
> Adding parenthesis to the RHS tells Perl to parse things differently:
> the comma is not the top level operator, but a lower level operator.
> In fact, the parenthesis on the RHS aren't any more magical than the
> parenthesis here:
>
>     3 * (4 + 5);
>
> which is parsed differently compared to:
>
>     3 * 4 + 5;
>
>
>
> Abigail
>


More information about the london.pm mailing list