Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: s///g within m//g regions

by almr (Sexton)
on Nov 09, 2021 at 15:52 UTC ( [id://11138627]=note: print w/replies, xml ) Need Help??


in reply to Re: s///g within m//g regions
in thread s///g within m//g regions

Yes! Except the above breaks, because the inner s/// kills the existing capture groups. So, those must be saved. E.g.

s{ ( ^ \#[ ]START \n ) ( .*? ) ( ^ \#[ ]END \n ) }{ my @m = @{^CAPTURE}; $m[ 0 ] . ( $m[ 1 ] =~ s/^[ #]+//rmg ) . $m[ 2 ]; }xmesg;

Replies are listed 'Best First'.
Re^3: s///g within m//g regions
by ikegami (Patriarch) on Nov 10, 2021 at 17:31 UTC

    @{^CAPTURE} is new to me!

    (hmm, I wonder if String::Substitution can be optimized on version where this is available.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-03-28 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found