Just a parenthetic note: From Perl version 5.14 on, the /r modifier for s/// and tr/// operators allows them to return the substituted/transformed string for a slightly simpler expression:
Works with $1 =~ tr{\n}{}cdr as well. See s/// in Regexp Quote-Like Operators, and tr/// in Quote-Like Operators.c:\@Work\Perl\monks>perl -wMstrict -le "my $c = qq{foo /* bar \n baz \n boff \n */ fum}; print qq{<<$c>>}; ;; $c =~ s{ /[*] (.*) [*]/ }{ $1 =~ s{[^\n]}{}xmsrg }xmsge; print qq{[[$c]]}; " <<foo /* bar baz boff */ fum>> [[foo fum]]
Give a man a fish: <%-{-{-{-<
In reply to Re: nested replace
by AnomalousMonk
in thread nested replace
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |