On 5/25/05, Jay Savage <[EMAIL PROTECTED]> wrote:
> On 5/24/05, Robert Citek <[EMAIL PROTECTED]> wrote:
> > I like your idea. Unfortunately, the above works only in the special
> > case where the regular expression match is actually a single-
> > character, exact match.
> >
> > Regards,
> > - Robert
>
> It works for your example case; if you have a different case in mind,
> there will be a different solution. There is rarely a "general case"
> in perl, especially if the goal is to keep the code a reasonable
> one-liner invoked with 'perl -le'. constructions using map in
> particular yeild very specific results.
>
> If you want to avoid while without using map you can also do something
> like the following:
>
> $_ = $foo; s/e/push @bar, pos/eg;
>
> Make sure to copy the variable, though; s/// will mangle it. Note, too, that
>
> /e(?{push @bar, pos})/g;
>
> should work, but seems to ignore the /g.
On the other hand,
s/e(?{push @bar, pos})/e/g;
seems to work as expected.
--jay
--------------------
daggerquill [at] gmail [dot] com
http://www.engatiki.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>