in reply to Re: Disambuating $ in (especially /m) regexps
in thread Disambuating $ in (especially /m) regexps

I like that unconventional use of /x. Thanks.
  • Comment on Re^2: Disambuating $ in (especially /m) regexps

Replies are listed 'Best First'.
Re^3: Disambuating $ in (especially /m) regexps
by BillKSmith (Monsignor) on Jan 05, 2016 at 22:04 UTC
    You must be careful not to match lines that are not consecutive.
    use strict; use warnings; my $string = "foo LAST\n" ." blftz\n" ."LINE fum\n" ; print "MATCH\n" if ($string =~ m/LAST$ .* ^LINE/xms) ;

    You could solve this with:

    print "MATCH\n" if ($string =~ m/LAST$ ..? ^LINE/xms) ;
    Bill