in reply to Re^2: A hint about using map
in thread Turning foreach into map?
Right, that's a point, but the way I look at it it would still work even if s/// was returning the changed string (except, of course, when the returned string was something like zero or an empty string).Really? Then what should s/// return if *no* substitutions took place? undef? That would make
fail to do the right thing most of the time as well - it would only work if the old list only contain strings that would be affected by s///. You would still need to write that as:@new_list = map {s/foo/bar/} @old_list;
most of the time.@new_list = map {s/foo/bar/; $_} @old_list;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: A hint about using map
by doom (Deacon) on Apr 08, 2005 at 20:31 UTC |