Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Searchin' through values

by vitoco (Friar)
on Dec 14, 2009 at 13:08 UTC ( #812704=note: print w/replies, xml ) Need Help??


in reply to Re: Searchin' through values
in thread Searchin' through values

I found very interesting this piece of code as an example for the \G pattern, but I noticed that x modifier was missing on each regexp AFAIK, but then tested if there was anything else I'm not awared.

Just as it is, it returns nothing on $pat. Then added the x modifier and got an endless loop!

I thought it was related to a note in perlre: "It is worth noting that \G improperly used can result in an infinite loop.", but a small trace using print "($pat)\n"; just before each redo shows that \G is always at the beginning of the argument, not after what was already matched.

I tried again removing pos() to see if that function resets the pointer... No luck!

Am I doing something wrong?

Replies are listed 'Best First'.
Re^3: Searchin' through values
by ikegami (Pope) on Dec 14, 2009 at 16:15 UTC
    It's because 'x' wasn't the only missing modifier. 'g' (to make the engine pay attn to pos) and 'c' (to prevent the engine from resetting pos) were also missing. Fixed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://812704]
help
Chatterbox?
[Corion]: Do you want to launch a script and keep the command prompt/console window open?
[Corion]: Do you want to wait for a key press before closing the window?
[LanX]: I want the command line in the history
[tye]: -Mouse
[Corion]: Option a) would mean launching cmd.exe /k c:\path\to\ batchfile- launching-perl- script.cmd. Option b) would be to add pause as the last line of said batch file.
[LanX]: First day after holidays ... and already stressed by the fact that colleagues changed stuff without communication ... apparently I'm the only one trying to fight entropy
[Corion]: LanX: The command is always in the history if you typed it in before. If you didn't type the command into the command line, it will not be there. I think there is doskey which can stuff command lines into the history
LanX damns the cult of CB ;-)
LanX WTF WTF WTF
[LanX]: please forget my last 3 posts

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2017-03-27 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.