in reply to Re: Search and replace with expansion
in thread Search and replace with expansion
Nice! But note that you can get the effect of the eval by adding a second /e modifier instead:
22:18 >perl -wE "my $s = '1 2 3*2 4 5x3'; $s =~ s/(\d+)[xX*](\d+)\s*/q +q['$1 ' x $2]/gee; say qq[\n|$s|];" |1 2 3 3 4 5 5 5 | 22:19 >
Hope that’s of interest,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Search and replace with expansion
by McA (Priest) on Aug 07, 2014 at 12:40 UTC |