mr_p has asked for the wisdom of the Perl Monks concerning the following question:
Hello again Monks,
I wanted to know scope of threads when I include package. I have a package called SPFTP and wanted to know if global variables will be global only to each thread, meaning each thread will have their own global vairables.
SPFTP is package.
# some code here.... for (0 ..3)) { my $thr = threads->create ( sub { my global_var; use SPFtp qw(/^\$/); use SPFtp qw (Connect Login PrepareLsFtpList deleteFile Get +File GetFileSize Logout GetMessage CheckConnection); worker(); } )->detach(); } # Master Thread while (1) { my global_var; use SPFtp qw(/^\$/); use SPFtp qw (Connect Login PrepareLsFtpList deleteFile GetFile G +etFileSize Logout GetMessage CheckConnection); master(); }
The question is does any "our" variable that is declared in SPFTP.pm unique to its self/thread? Also, will global_var be global variables?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Scope of thread variable
by BrowserUk (Patriarch) on Apr 07, 2010 at 18:47 UTC | |
by mr_p (Scribe) on Apr 07, 2010 at 18:58 UTC | |
by BrowserUk (Patriarch) on Apr 07, 2010 at 19:27 UTC | |
by mr_p (Scribe) on Apr 07, 2010 at 19:38 UTC | |
by mr_p (Scribe) on Apr 08, 2010 at 15:37 UTC | |
by BrowserUk (Patriarch) on Apr 08, 2010 at 16:07 UTC | |
| |
|
Re: Scope of thread variable
by ikegami (Patriarch) on Apr 07, 2010 at 18:44 UTC | |
by BrowserUk (Patriarch) on Apr 07, 2010 at 18:53 UTC | |
by mr_p (Scribe) on Apr 07, 2010 at 18:55 UTC |