in reply to Re: A Functional Substitute
in thread A Functional Substitute
This, and BrowserUk's suggestion are both good ones. BrowserUk's I wasn't even aware of, and this one I had somewhat forgot about. However, I do like the consistency of having one method of doing it that works both standalone and in map. Although I usually argue that adding a variable at the end of a map block isn't that bad, I'm going to be a devil's advocate and argue against it here.
my @output = map { (my $i = $_) =~ s/foo/bar/; $i } @input;
Seems less readable to me than
my @output = map { $_ \~ s/foo/bar/ } @input;
And I like the use of 'map' instead of 'filter' (especially since I think of grep when I think of filter).
I guess it looks like personal preference here, so maybe I'll just perfect this one and keep it for myself (since I don't use $1 and $2 very often from what I've noticed, I wouldn't have to fix them just for myself).
-Bryan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A Functional Substitute
by jdporter (Paladin) on Aug 09, 2005 at 14:57 UTC | |
by mrborisguy (Hermit) on Aug 10, 2005 at 23:53 UTC |