CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [jazzo] insert numbers in array using standard input: Edit Log



FishMonger
Veteran / Moderator

Aug 21, 2012, 1:55 PM


Views: 3335
Re: [jazzo] insert numbers in array using standard input

-1 is used when specifying/accessing the last element in the array. It has nothing to do with the length (or size) of the array.


Code
my @array = qw|first second third fourth fifth|; 

print $array[-1]; # prints fifth
print $array[-2]; # prints fourth
print $array[-3]; # prints third



(This post was edited by FishMonger on Aug 21, 2012, 1:55 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Aug 21, 2012, 1:55 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives