in reply to Unshift and push inside of map operation.
The canonical form of map (according to me) is used to return a mapped version of the input:
One of the things I find particularly useful is that the block of code can evaluate to a list, including an empty one. Ie the output of map need not be the same length as the input. Eg@a = map { # A function of $_, eg: $_ . ".txt" } @a;
# Emulate grep with map @a = map { elementShouldBeIncluded($_) ? $_ : () } @a; # Double up the list @a = map { ($_, $_) } @a;
In this particular case, this feature may be exactly what you're after, depending on how what exactly your vendor supplied program does. Consider the following structure:
Hope that helps.@a = map { # Is it a dir? (-d $_) ? # Expand it (somehow) into a list of files turnDirIntoFilesUsingVendorProg($_) : # It's a file - pass it straight through $_ } @a;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unshift and push inside of map operation.
by juster (Friar) on Sep 23, 2008 at 19:15 UTC |