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

TIMTOWTDI

use strict; use warnings; use Test::More; my $in = 'A |simple*example| is |so*simple| to come*up |with these*days| according to some *experts*'; my $exp = 'A |simple-example| is |so-simple| to come*up |with these-days| according to some *experts*'; my $start = qr/\|/; my $stop = qr/\|/; my $got; for ( split /($start|$stop)/s, $in) { if ( /$start/.../$stop/ ) { #print "<$_>"; s/\*/-/gs; } $got .= $_; } is($got,$exp); done_testing;

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^6: s///g within m//g regions
by LanX (Saint) on Nov 09, 2021 at 20:51 UTC
    > TIMTOWTDI

    use strict; use warnings; use Test::More; my $in = 'A |simple*example| is |so*simple| to come*up |with these*days| according to some *experts*'; my $exp = 'A |simple-example| is |so-simple| to come*up |with these-days| according to some *experts*'; my $start = qr/\|/; my $stop = qr/\|/; my $got = join "", map { /$start/.../$stop/ ? s/\*/-/gr : $_ } split /($start|$stop)/s, $in; is($got,$exp); done_testing;

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery