in reply to Multiple variable assignments with RexExp
Here's a somewhat heretical solution:
Yes, map in void context. It is acting as an operator, modifying its arguments as do chomp, splice, and others. The substution acts on $_ which is, in map's codeblock, an alias to the current list argument This won't work for constant arguments, of course.map {s/\n/<br\/>/g} $var1, $var2;
Go ahead and assign from it if you need statistics on the number of substitutions. The style campaign against map in void context makes the device all the more helpful at calling attention to using map for side effects.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Multiple variable assignments with RexExp
by rob_au (Abbot) on May 22, 2002 at 05:23 UTC |