Assigning anonymous hash to a list

Paul LeoNerd Evans leonerd at leonerd.org.uk
Tue Jul 30 20:19:01 BST 2013


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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
Url : http://london.pm.org/pipermail/london.pm/attachments/20130730/5b6f0fb0/signature.pgp


More information about the london.pm mailing list