Arrays are a very useful data-type in all programming languages. Although their syntax and implementation (and therefore efficiency) vary between programming languages, the general tools and methods for manipulating them are very similar.
Perl can only easily handle 1 dimensiona arrays.
Looping through an array with foreach
Last updated at 11:52 AM on Wednesday 5th September, 2007 by Administrator
Beware the ugly way:
It is prettier to assign the element of the array to named variable.
foreach my $element (@array)
Creating an array
Last updated at 11:53 AM on Wednesday 5th September, 2007 by Administrator
my @array = (0, 1, 2, 3);
$array = 2;
Add to end of an array
Last updated at 08:38 PM on Monday 12th November, 2007 by Administrator
To add to the right-side:
@arr = ("a", "b");
To add to the left-side:
@arr = ("b", "c");