Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

regular expression hanging inside a child thread

by dxxd116 (Beadle)
on Apr 17, 2009 at 09:42 UTC ( #758155=perlquestion: print w/replies, xml ) Need Help??
dxxd116 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, Monks:
I have been stuck by this problem for a few days. I have a somehow complicated regular expression inside a child thread in a multi-threaded program.
my ($mail)=$string=~m/([\w._+-]+@(?:[\w-]+\.)+\w{2,5})(?<!\.jsp|\.asp| +\.jpg|\.htm)\W/mi;
When the text to be matched($string) is a little over 1 Megabytes, this regexpression runs forever and never return.
But when I run a single-threaded version of the same program, it works perfectly fine(The regex returns instantly). I am wondering whether there are some settings or limits imposed on the child thread of a multi-threaded program. Could anyone here enlight me on that?
I am running ActiveState Perl 5.10.0 on Windows Platform. Thanks in advance.

Replies are listed 'Best First'.
Re: regular expression hanging inside a child thread
by ikegami (Pope) on Apr 17, 2009 at 14:00 UTC

    It's been reported already with no resolution.

    You could force the regexp to be recompiled in each thread for now:

    # Globals my $expensive_re_str = ''.qr/([\w.+-]+@(?:[\w-]+\.)+\w{2,5})(?<!\.(?:jsp|asp|jpg|htm)\W/i; my %expensive_re; # Workaround for perl bug RT#55600 my $expensive_re = $expensive_re{$thread_id} ||= qr/$expensive_re_str/; my ($mail) = $string =~ m/$expensive_re/;
      That workaround is great! Thank you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://758155]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2018-01-21 01:58 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.