[plug] [Perl] Hello gurus
    Anthony J. Breeds-Taurima 
    tony at cantech.net.au
       
    Fri Jan  3 09:35:52 WST 2003
    
    
  
On Fri, 3 Jan 2003 levsky at rave.iinet.net.au wrote:
> $test[$#test-1];  (assuming there's more than one element in the array)
Or you can use a "negative index"
-1 = the last
-2 = the second last.
ie
---
@ARGV=qw(one two three 4 five);
print $#ARGV,"\n";             # 4
print "@ARGV\n";               # one two three 4 five
print $ARGV[$#ARGV],"\n";      # five
print $ARGV[$#ARGV-1],"\n";    # 4
print $ARGV[-2],"\n";          # 4
---
YMMV
Yours Tony
   Jan 22-25 2003           Linux.Conf.AU            http://linux.conf.au/
		  The Australian Linux Technical Conference!
    
    
More information about the plug
mailing list