Array Variables in Perl
Tutorials Shared by the Internet Community
Total Hits - 24014
Total Votes - 116 votes
Vote Up - 52 votes
Vote Down - 64 votes
Domain - blog.codebeach.com
Category - Perl & CGI/Getting Started
Submitted By - Devesh Khanna
Submitted on - 2008-03-16 01:01:33
You’ve already seen simple arrays. We used them for the “command line” variables. Simple arrays begin with the “@” symbol. If you want a specific value from the array, you index that value using its number in the array. If you want the first item from the array, you ask for “$ARGV”. If you want the third item, use “$ARGV”.
Arrays always use the “@” symbol. Scalar variables always use the “$” symbol. A piece of an array is always a scalar. (You can’t have arrays inside of arrays in simple Perl.) That's why you use “@” to refer to the entire array, and “$” to refer to items within the array. If you want to know how many values are in an array, use the scalar variable $#ARRAY. This is actually the index of the last element, so for the count, you’ll need to add one. ...