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.)