Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: nested replace

by AnomalousMonk (Archbishop)
on Mar 18, 2016 at 13:22 UTC ( [id://1158226]=note: print w/replies, xml ) Need Help??


in reply to nested replace

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:

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]]
Works with  $1 =~ tr{\n}{}cdr as well. See  s/// in Regexp Quote-Like Operators, and  tr/// in Quote-Like Operators.


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1158226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2024-04-18 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found