Assigning anonymous hash to a list

Joseph Werner telcodev at gmail.com
Tue Jul 30 20:34:48 BST 2013


I disagree.

This is a straightforward  assignment to the first element of a list.
Precedence is not involved. A scalar assignment vs a list assignment
is the issue.

Christian

(oh boy, call out the hounds...)


On Tue, Jul 30, 2013 at 3:19 PM, Paul LeoNerd <leonerd at leonerd.org.uk> wrote:
> On Tue, 30 Jul 2013 19:54:46 +0100
> gvim <gvimrc at gmail.com> wrote:
>
>> my ($str, $ref) = 'text', {a => 1, b => 2, c => 3};
>
> Precedence.
>
> This parses as
>
>   (  my ( $str, $ref ) = 'text' ),   { a => 1, b => 2, c => 3 };
>
> To make it work as you expect use parens on the RHS as well:
>
>   my ( $str, $ref ) = ( 'text', { a => 1, b => 2, c => 3 } );
>
> --
> Paul "LeoNerd" Evans
>
> leonerd at leonerd.org.uk
> ICQ# 4135350       |  Registered Linux# 179460
> http://www.leonerd.org.uk/



-- 
Best Regards,
[Joseph] Christian Werner Sr
C 360.920.7183
H 757.304.0502
Txt 757.304.0502


More information about the london.pm mailing list