I've been using perl on and off for 8 years but I'm still pants at it. My current failure lies is in (not) getting a progress bar to work.
WHAT I THINK MY CODE SHOULD DO:
I simply want to have a thread print a dot to a user's screen every 10 seconds via HTTP (to keep the browser connection alive and stop it timing out and also to indicate the script is still running) until another thread finishes.
WHAT MY CODE ACTUALLY DOES:
Nothing gets printed to the screen by the progress bar. When the work thread rejoins the main thread it posts its results to the screen (if the browser hasn't timed out), or the browser times out. No sign of my
THE CODE:
# set a shared value of TRUE for running the progress bar
my $keepRunningProgressBar : shared = 1;
# Set the progress bar running indefinitely
my $progressBar = threads->create(sub { while ($keepRunningProgressBar
+ == 1) {print "<img src=\"http://www.thepaty.plus.com/dot.gif\">"; sl
+eep(10);} });
$progressBar->detach;
# Now do stuff in the work thread
my $threadForSpidering = threads->new(\&workthread, $category, $conten
+ts, $userRunningBot,$userIPAddress);
#The work thread finished
$threadForSpidering->join;
#And tells the progress bar to stop running
$keepRunningProgressBar = 0;
What am I doing wrong here??
Cheers
Dan
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.