1 | Note that @fred (an array) and $fred (a scalar) are totally different variables |
2 | The elements of @fred are indexed starting at 0 (not 1, as in Fortran) |
3 | Elements are referenced by $ NOT @ |
4 | $a = $fred[0]; # is first element in @fred |
5 | PERL interpolates arrays as well as scalars: |
6 | $fred[0]= "First element of \@fred"; |
7 | Indices may be arbitrary integer expressions: |
8 | @fred = (0..10); $a = 2; |
9 | $b = $fred[$a-1]; # sets $b equal to 1 |