in reply to Thread crash
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 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__
#!/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__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Thread crash
by DrCarib (Initiate) on Nov 21, 2007 at 17:42 UTC | |
by gam3 (Curate) on Nov 21, 2007 at 17:45 UTC |