|
Once we have looked at the scalar variable we need to get a bit more complicated. A more interesting kind of variable is the array variable which is a list of scalars (ie numbers and strings). Array variables have the same name convention as scalar variables except that they are prefixed by an @ symbol. The following statement assigns two array variables, @trees and @colour:
@trees = ("ash", "oak", "pine");
@colour = ("red", "blue");
You can access the data in an array by using indices starting from 0, and square brackets are used to specify the index. The expression
$trees[2]
would return oak. Notice that the @ has changed to a $ because eels is a scalar. 
|