in reply to Array of ($1, $2, ...) in replacement part of s///?
You can use the code assertion regex to do this. (See perlre "Extended patterns" for details).
P:\test>perl -Mstrict -wle" my $s = 'the quick brown fox jumps over the lazy dog'; my @bits; $s =~ s[ .(.)(?{ push@bits,$^N }) ..(..)(?{ push@bits,$^N }) .] [ print join'-',@bits; ]gex;" h-qu h-qu-k-ro h-qu-k-ro- -x h-qu-k-ro- -x -m- o h-qu-k-ro- -x -m- o-r-he h-qu-k-ro- -x -m- o-r-he-a- d
Note: I've split the 'one-liner' up to avoid the code wrap mangler.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Array of ($1, $2, ...) in replacement part of s///?
by sleepingsquirrel (Chaplain) on Jan 28, 2004 at 21:33 UTC | |
by ysth (Canon) on Jan 28, 2004 at 21:51 UTC |