[Chicago-talk] Using "@" to reference element in array

tiger peng tigerpeng2001 at yahoo.com
Thu Oct 1 15:07:27 PDT 2009

@array[2] is just an array with one element. ('a') ; and print prints out the element.

From: Jay Strauss <me at heyjay.com>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Thu, October 1, 2009 4:42:09 PM
Subject: [Chicago-talk] Using "@" to reference element in array


I just got a script at work where the writer used:

my @array = qw[adf af a adf asdfd];
print @array[2];

And it works!!

I thought that notation didn't go into effect until Perl6.

I've always done $array[2], and never tried the style above.  Is there any reason not to adopt the style above in future Perl5 programming?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20091001/dfe4e6fb/attachment.html>

More information about the Chicago-talk mailing list