Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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.

Comment on regular expression hanging inside a child thread
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://758155]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-10-21 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls