Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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 musing on the Monastery: (6)
As of 2017-06-24 18:20 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (562 votes). Check out past polls.