I wrote a script that scrape information off staples.com and I'm getting different results if I run it stand alone or I fork the script. running the script stand alone I get the expected results and when forking the script it seems like it ignores the <title> tag. any help is appreciated: this is part of the script:
sub GetStaples { my $oem_PN = $_[0]; my $ItemDesc = $_[1]; my @ItemDesc = split(',',$ItemDesc); my $Item; my $price; my $description; my $type; my $title; my $numofitems; my $agent = WWW::Mechanize->new(autocheck => 1, cooki +e_jar => undef); $agent->get("http://www.staples.com/webapp/wcs/stores +/servlet/home? &langId=-1&storeId=10001&catalogId=10051"); $agent->form_name("headerSearchForm"); $agent->field("searchkey",$oem_PN); $agent->click(); my $stream = HTML::TokeParser->new(\$agent->{content} +); open(OUTFILE, ">>output.html") or die "Can't open out +put.txt: $!"; print OUTFILE $agent->content(); close(OUTFILE); my $tag = $stream->get_tag("title"); $title = $stream->get_trimmed_text("/title"); print "Title:".$tile."\n"; if ($title !~ /that was easy/){...................... +..
and this is how I fork the script
$pidStaples=fork(); die "Cannot fork: $!" if (! de +fined $pidStaples); if (not defined $pidStaples) { print "esources not av +ilable.\n"; } elsif ($pidStaples == 0){ GetStaples($ref->{OEM_ +PartNum},$ref->{Description}); exit(0); }
the parameters are being passed successfully and if you noticed I've created an outputfile.html to debug the agent- >content and it comes back as expected. even with that I can's get $title back

May 04, 2008 at 17:17 UTC Janitored by McDarren: Added code tags


In reply to [Click the star to watch this topic] weird issue with HTML::TokeParser and Fork by arikamir

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.