1 |
@chars = map( expr , @nums);
|
2 |
Here expr is some Expression or Block which accesses variable $_
|
3 |
map sets $_ to be succesive values in list @nums and returns the successive results of executing BLOCK expr with each value of $_
-
These results are returned in list context and may give zero one or more entries into total list @chars
|
4 |
A similar construct is grep which acts like map but returns a list containing just the entries in @nums for which expr is TRUE
-
This is clearly like UNIX grep as
-
grep ( /regexp/, @listoflines ); # returns just those lines matching regexp
-
$_ is set by reference to $listoflines[0...] and so altering $_ will alter original @listoflines
|