Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Thread crash

by gam3 (Curate)
on Nov 21, 2007 at 17:16 UTC ( [id://652179]=note: print w/replies, xml ) Need Help??


in reply to Thread crash

I have verified that your code crashed perl v5.8.8.
This code does seem to run however.
#!/usr/bin/perl use threads; use Thread::Semaphore; sub bad { sub mysub { print "my sub : $1 $2\n"; } $a = "Hi there and hi there.\n"; $a =~ s/(\w+ \w+)(?{mysub();})//gi ; } sub mythread { print "begin\n"; print "end\n"; } my $thr = threads->new(\&bad); @r=$thr ->join(); my $thr = threads->new(\&mythread); @r=$thr ->join(); __END__
Also $a =~ s/(\w+ \w+)/&mysub()/ge; seems to give the same output as your code and also does not seem to cause the crash. You do need to worry about the output of the function though.
#!/usr/bin/perl use threads; use Thread::Semaphore; sub mythread { print "begin\n"; print "end\n"; } sub mysub { print "my sub : $1 $2\n"; ''; } $a = "Hi there and hi there.\n"; $a =~ s/(\w+ \w+)/&mysub()/ge; my $thr = threads->new(\&mythread); @r=$thr ->join(); __END__
-- gam3
A picture is worth a thousand words, but takes 200K.

Replies are listed 'Best First'.
Re^2: Thread crash
by DrCarib (Initiate) on Nov 21, 2007 at 17:42 UTC
    Thank you very much for your fast replies. This is perfect for what I need to do, but I was not aware of this syntax. I'd be interested though in knowing if the crash was caused by my weird code (I'm newbie to Perl) or by an interpreter problem.
      Your weird code found an interpreter problem.
      -- gam3
      A picture is worth a thousand words, but takes 200K.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://652179]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found