in reply to Re^3: "Attempt to free unreferenced scalar" and "Scalars leaked: 1" ?
in thread "Attempt to free unreferenced scalar" and "Scalars leaked: 1" ?
Thanks a lot! BrowserUk. You are really great!
I'm sorry in fact there are some typos such as exported function names and missing the "1;" at the end of test.pm, etc. I should've double check my post...
But I am really weak on this part. The syntax to specify the subroutine-name in threads->create is confusing to me. And I guess maybe the latest release has addressed this problem (passing subroutine-name as string instead of code-ref). I have another question about code ref. In fact, I want my code to deal with unknown subroutine name beforehand. Instead, the name may be given in a parameter file in XML like the following:
<thread> <module>module_name</module> <subroutine>subroutine_name</subroutine> </thread>
A script reads the file and put modulename in var "$module" and subroutinename in "$subroutine". Then, what is the correct syntax to create a thread for "$subroutine"? I guess I have to use Module::Load to dynamically load a module first and then call threads->create to run a thread for a subroutine. Will this cause some problem?
And I rewrite 2nd part as follows. Please help. Thanks!
use threads; use test; my $thread=threads->create('forthread', (argument)); $thread->join(); exit(0);
package test; require Exporter; our @ISA =qw(Exporter); our @EXPORT =qw(forthread); our @VERSION =1.0; sub forthread{ my (argument)=@_; my $thread=threads->create('another', (argument)); $thread->join(); return 0; } #forthread sub another{ return 0; } #another
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: "Attempt to free unreferenced scalar" and "Scalars leaked: 1" ?
by BrowserUk (Patriarch) on Apr 01, 2007 at 09:34 UTC | |
by licht (Novice) on Apr 01, 2007 at 09:57 UTC | |
by BrowserUk (Patriarch) on Apr 01, 2007 at 10:06 UTC | |
by licht (Novice) on Apr 01, 2007 at 10:43 UTC |