Individual element in an array can be referred with their subscript position in the array. The first element in an array is always at position "0". An array structure is always circular.
#!/usr/bin/perl print "content-type: text/html \n\n"; @array = ("Quarter","Dime","Nickel"); print "@array\n"; print "$array[0]\n"; # Prints the first element in the array print "$array[1]\n"; # Prints the second element in the array print "$array[2]\n"; # Prints the third element in the array print "$array[-1]\n"; # Prints the last element in the array print "$array[-2]\n"; # Prints second to last element in the array
Output: ------- Quarter Dime Nickel Quarter Dime Nickel Nickel Dime
AllBlogToolsFacebook comments for blogger brought to you by AllBlogTools.com , Get Yours?