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

Jay Strauss me at heyjay.com
Thu Oct 1 19:53:30 PDT 2009


You are right.  I don't have warnings turned on.  I was just looking over
his script.  (normally I use warnings)

Thanks

Jay

On Thu, Oct 1, 2009 at 5:00 PM, Kent Cowgill <kent at c2group.net> wrote:

>
> On Oct 1, 2009, at 4:42 PM, Jay Strauss wrote:
>
>  Hi,
>>
>> 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!!
>>
>
> You must not have warnings turned on.
>
> @array[ @indices ] is a valid way to produce a slice of array values, but
> when there's only one index, the @ sigil doesn't make much sense.  And when
> you have warnings turned on, perl tells you that it doesn't make sense:
>
> Scalar value @array[2] better written as $array[2] at <filename> line <blah
> blah>.
>
>
> Kent Cowgill                                     kent at c2group.net
>
> http://kentcowgill.org/blog           http://youtube.com/kcowgill
> http://kentcowgill.org/photos   http://flickr.com/people/kcowgill
>
>
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20091001/70fbefb9/attachment.html>


More information about the Chicago-talk mailing list