in reply to simple array question
By now you have the help you were looking for, but it may help a little to understand why Perl works like that. Larry Wall designed parts of Perl with the idea that different things should look different. That is a reason why Perl uses $, @ and % in front of variables and things. Things that have $ in front act like scalar values (numbers, strings and stuff like that). Things that have @ in front act like arrays or lists of things (don't get hung up about the difference at this point though). Things that have % in front act like hashes (those are really important to understand in Perl, but cause a lot of initial grief for beginners).
Arrays and hashes are both indexed variables - they hold lots of stuff and you need an index to select the particular element you are interested in. Arrays are indexed using numbers starting from 0 using syntax that looks like: $array[$index]. The $ out the front tells you that you are getting a scalar value. The [$index] bit selects the element 'indexed' by the numeric value in $index.
Hashes are indexed by strings. Accessing an element of a hash looks like: $hash{$index}. Still the $ out front to tell use we are getting a scalar value, but now we use curly brackets instead of square brackets and now $index contains any string we care to use.
Of course there is a whole lot more to it than that which you will learn along the way. Just remember that in general Perl tries to make things that are different look different.
|
|---|