On Sunday 08 May 2005 00:13, amr wrote:
How can I call the last element in the array?
I try the pop and it does the job but I think there is another way?
Of course, TMTOWTDI (http://catb.org/~esr/jargon/html/T/TMTOWTDI.html)
$ARRAY[$#ARRAY--]
Oh wow. Did you try that? You do realise that modifying $#ARRAY changes the size of @ARRAY?
$ perl -le' @ARRAY = "A" .. "Z"; print "Size: " . @ARRAY, " $ARRAY[$#ARRAY]"; print "Size: " . @ARRAY, " $ARRAY[$#ARRAY--]"; print "Size: " . @ARRAY, " $ARRAY[$#ARRAY--]"; print "Size: " . @ARRAY, " $ARRAY[--$#ARRAY]"; print "Size: " . @ARRAY, " $ARRAY[--$#ARRAY]"; ' Size: 26 Z Size: 26 Size: 25 Size: 24 W Size: 23 V
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>