Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Some odd ambiguity in this regex (updated)

by AnomalousMonk (Archbishop)
on Jun 05, 2020 at 16:17 UTC ( [id://11117722]=note: print w/replies, xml ) Need Help??


in reply to Some odd ambiguity in this regex

Further to hippo's post:

... something in the steps you are not showing us.
misterperl:   It's easy to contrive that scenario entirely separate from debug mode:
c:\@Work\Perl\monks>perl -wMstrict -le "$_ = '1223w3433.45+34'; ;; /\d\D*/g; printf qq{'$&' } while /\d\D*/g; " '2' '2' '3w' '3' '4' '3' '3.' '4' '5+' '3' '4'
m//g in scalar or void context "remembers" the point at which a previous match ended and continues matching from that point. See pos.

Update: See what happens if the side-effect-producing, void context
    /\d\D*/g;
statement is changed to
    () = /\d\D*/g;
(i.e., if list context is imposed).


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

Replies are listed 'Best First'.
Re^2: Some odd ambiguity in this regex (updated)
by ikegami (Patriarch) on Jun 06, 2020 at 21:11 UTC

    It's often the result of using the nonsensical if (/.../g)

    $ perl -e' $_ = "abc"; if (/\w/g) { CORE::say for /(\w)/g; } ' b c
Re^2: Some odd ambiguity in this regex (updated)
by misterperl (Pilgrim) on Jun 05, 2020 at 16:59 UTC
    I dont think I "contrived" anything. I did "R" and the first line was :
    $_= '1223w3433.45+34';
    then I did the "x". If the debugger works as you suggest, then it's not working right. It should interpret the expression correctly; if something isn't reset (which doesnt make sense ,since this happens on line 2) than it needs to get reset..

    Larry?

    But, you're correct it IS a debugger thing because the interpretation is correct outside dbg...

      Please apply this single line and show us the result:

      DB<5> x $_='12a3b'; /\d\D*/g 0 1 1 '2a' 2 '3b' DB<6>

      > But, you're correct it IS a debugger thing

      Very unlikely.

      And you've already been quick to blame Perl in the past.

      Edit

      We need a possibility to reproduce your problem before searching a hypothetical bug.

      So please reproduce, and tell us the versions of perl and the debugger.

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

Log In?
Username:
Password:

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

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

    No recent polls found