[Chicago-talk] Using "@" to reference element in array
Randal L. Schwartz
merlyn at stonehenge.com
Thu Oct 1 16:05:58 PDT 2009
>>>>> "Jay" == Jay Strauss <me at heyjay.com> writes:
Jay> print @array[2];
Think of that as the same as @array[2..2], as in, a list that has
only one element. "print" prints a single element list in the same
way that it prints a scalar.
But let's put this on the left side of an assignent:
$array[2] = @ARGV; # get the count of arguments into $array[2]
@array[2..2] = @ARGV; # get the first argument ($ARGV[0]) into $array[2]
quite different reactions!
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
More information about the Chicago-talk
mailing list