( categories: array )
- BASIC
The general way of iteration is using foreach:
# print all elements of an array
foreach my $element ( @array )
{
print $element . "\n";
}
- ADVANCED
If you want to iterate through an array to obtain a subset of its elements you may use grep:
# get all elements that begin with 'fun'
@fun_array = grep /^fun/ @array;
If you want to do something to each element of an array, you can use map:
# convert all elements to lowercase
@lowercase = map { lc } @array;





