New to threads, and really new to the deeper parts of perl, been using
it for years as a all purpose scripting solution, but just now getting
into embedding it and using it for rapid prototyping. Basic outline of
program, I have a controller which will be pretty much the heart of the
program, setting things up, and several classes, one in particular that
we'll call Downloader.
I'm trying to make this multithreaded, so that I can have multiple
downloaders going at once, but Downloader being a class instance is
throwing me off. It may just be syntax, but my googling didn't produce
any examples of doing threading with a class instance.
my $downloader = eval { new Downloader();} or die (@_);
my $thread1 = threads->new($downloader->fetch,
"http://www.webaddress.com", \%siteHash);
$thread1->join;
I've tried putting \& in front of downloader->fetch, as well as putting
it in front of fetch itself, but no luck. Right now its just executing
the fetch function in downloader and generating an error :
thread failed to start: Undefined subroutine
&main::http://www.webaddress.com called
Any help appreciated.
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.