Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^6: Regex troubles...

by AnomalousMonk (Archbishop)
on Apr 23, 2016 at 20:16 UTC ( [id://1161329]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Regex troubles...
in thread Regex troubles...

If I put the for-loop back into the unrolled loop code, I start to see weird stuff again (still Strawberry 5.14.4.1):

c:\@Work\Perl\monks>perl -wMstrict -le "for my $string (qw(ab1b2b3b4d ab5b6b7d ab8b9d abxd ad)) { my @two; my @matches = $string =~ /(a) (?: (b.) (?{ push @two, $2 }))+ (d)/x; print qq{'$string' -> all:(@matches) -> 2:(@two)}; } " 'ab1b2b3b4d' -> all:(a b4 d) -> 2:(b1 b2 b3 b4) 'ab5b6b7d' -> all:(a b7 d) -> 2:() 'ab8b9d' -> all:(a b9 d) -> 2:() 'abxd' -> all:(a bx d) -> 2:() 'ad' -> all:() -> 2:()
What Perl version are you using?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^7: Regex troubles...
by choroba (Cardinal) on Apr 23, 2016 at 20:32 UTC
    Probably related to the changes in perl 5.18.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Indeed. Using a package global instead of a lexical makes everything right as rain:

      c:\@Work\Perl\monks>perl -wMstrict -le "print qq{perl version: $]}; ;; for my $string (qw(ab1b2b3b4d ab5b6b7d ab8b9d abxd ad)) { local our @two; my @matches = $string =~ /(a) (?: (b.) (?{ push @two, $2 }))+ (d)/x; print qq{'$string' -> all:(@matches) -> 2:(@two)}; } " perl version: 5.014004 'ab1b2b3b4d' -> all:(a b4 d) -> 2:(b1 b2 b3 b4) 'ab5b6b7d' -> all:(a b7 d) -> 2:(b5 b6 b7) 'ab8b9d' -> all:(a b9 d) -> 2:(b8 b9) 'abxd' -> all:(a bx d) -> 2:(bx) 'ad' -> all:() -> 2:()
      (I should have realized...)


      Give a man a fish:  <%-{-{-{-<

Re^7: Regex troubles...
by Anonymous Monk on Apr 23, 2016 at 20:20 UTC
Re^7: Regex troubles...
by Anonymous Monk on Apr 23, 2016 at 20:29 UTC

    Try putting it in a file and running from there. Personally I would not trust Window's shell quoting.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-23 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found