Hello, I am using perlthrtut module for perl thread, I have a problem while accessing shared variable that i defined before creating threads.
I created shared hash with use threads:shared. and then created a thread and called a subroutine for that thread. into that subroutine i am calling another perl module. i need to accces this shared hash into the perl module i m calling from subroutine. I could get the thread Id there but could not geting values that i shared or value that i am passing as a parameter list with thread->create(\&sub , %hash).
Here is code.
use threads;
use threads::shared;
use APP::plugin;
%hsh :shared;
thread->create(\&subrt, %hsh);
sub subrt{
my %args =@_;
plugin->execute(%hsh);
}
Code for Plugin module
package plugin;
execute{
my %abc =@_;
my %shsh = %hsh;
foreach $keys (%abc){ print $keys."---".$abc{$keys};}
}
I am not geting any paramter value i passed or even if i tried to access the shared hash that is also not avaialable in execute.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.