develooper Front page | perl.perl6.users | Postings from May 2021

In regexes with :P5 compatibility turned-on, do embedded modifierswork?

Thread Next
From:
Joseph Brenner
Date:
May 23, 2021 02:04
Subject:
In regexes with :P5 compatibility turned-on, do embedded modifierswork?
Message ID:
CAFfgvXUQwvTSLV_NwR_e3bJ7U7WQPDuKybSiJy90YDax88ys4A@mail.gmail.com
It's looking to me like perl5's embedded pattern modifiers don't work
when used with raku's :P5 compatibility modifier...

printf "%-25s", "Trying raku style: ";
if "this" ~~ m/ ^ <[a..z]> /         { say "good"; } else { say "ng"; }

printf "%-25s", "Trying :P5 without (?^x: ";
if "this" ~~ m:P5/^[a-z]/            { say "good"; } else { say "ng"; }

printf "%-25s", "Trying :P5 with (?^x: ";
if "this" ~~ m:P5/(?^x: ^ [a-z] )/   { say "good"; } else { say "ng"; }

printf "%-25s", "Trying :P5 with (?^i: ";
if "this" ~~ m:P5/(?^i:^[a-z])/      { say "good"; } else { say "ng"; }

# OUTPUT:
# Trying raku style:       good
# Trying :P5 without (?^x: good
# Trying :P5 with (?^x:    ng
# Trying :P5 with (?^i:    ng

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About