Sorry if i'm not doing this right, still rather new to perl and new to this website.
This keeps happening to me and i'm not sure why, i've written scripts that will check to see if a webpage is accessible and if it is I use threads to make a new thread in the program to notify me via twitter (just testing, the sub will do other things)
I use a while(1) loop to continually check the webpage via WWW::Mechanize, and if its live, it'll create the threads, what happened a couple times if the program runs for awhile, is that when it goes to create the thread, i get an Out Of Memory error and i'm not sure how to avoid this.
--Code--
use WWW::Mechanize;
use HTTP::Cookies;
use threads;
$|=1;
my $cookie_jar = HTTP::Cookies->new;
$mech = WWW::Mechanize->new(
agent => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:21.0)',
cookie_jar => $cookie_jar,
timeout => "15",
autocheck => 0);
$url = 'http://www.fwrd.com/product-military-boots/YEF3-MZ2/';
# page will default to error page if not around...
$delay = 15;
check();
sub check {
print "[x] starting...\n";
while(1) {
$resp = $mech->get($url);
if((!$resp->is_success) || ($resp->request->uri =~ m/error/i)) {
print "."; }
else {
for $sz (1..5) {
$thread = threads->new( sub { notify_plz($sz) });
my $tid = $thread->tid;
push (@Threads, $thread);
$thread->detach();
}
# we saw the page , exit
exit;
# end what we do if its found
}
sleep $delay;
}
}
not sure what i'm doing wrong,any help is appreciated, didnt post notify_plz cuz the script doesnt even seem to get to that point.