On Wed, Nov 19, 2003 at 08:23:30PM +0000, Smylers wrote:
> This, however, is irritating:
>
> my @new = map { s:e/$pattern/$replacement/; $_ } @old;
>
> I forget the C<; $_> far more often than I like to admit and end up with
> an array of integers instead of modified strings.
That one gets me every now and then too.
> So I'd like a more elegant way of writing that -- but I don't think
> making the return value of C<s///> more complicated (and duplicating
> data in the process) would be a nett gain.
What if the method form of s/// didn't mutate the string, but returned
the mutated result? Then, you'd just need to do something like:
my @new = map { $_.s:e/$pat/$rep/ } @old
Except I don't know how the method form of s/// would be spelt.
$string.s:e/$pat/$rep/; # . and ~~ are almost the same?
$string.sub($pat,$rep,"each"); # ick.
$string.sub:e($pat,$rep); # hmm.
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]