I think I need to give everyone more to go on, so here it is. My matching code looks like the following.
while (content =~ m%One(.*?)three(.?)five\s+six(.*?)this%gs) { $var1 = $1 ; $var2 = $2 ; $var3 = $3 ; print "$var1\t$var2\t$var3\n" ; }
It gives me output that looks like you would expect, say, for example:
two four sevenWhen the code hangs, it prints out the same thing, but then nothing more.
Now, I've made the following change in keeping with your suggestion.
while (content =~ m%One(.*?)three(.?)five\s+six(.*?)this%gs) { print(STDERR "[", pos($content), "]") ; $var1 = $1 ; $var2 = $2 ; $var3 = $3 ; print "$var1\t$var2\t$var3\n" ; }
I'm relatively new to PERL and not a professional coder, so I'm not sure what this is supposed to produce, but here's an example of what I am getting.
[ two four seven 48430]
On another match, however, it gives me:
[48226] three more numbers
When it hangs, it gives me the following.
[50757] first three numbers second three numbers third three numbers [51826][52896]
Does this help with understanding the problem?
In reply to Re^2: Regex infinite loop?
by Ninth Prince
in thread Regex infinite loop?
by Ninth Prince
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |