Hi, everyone. I am having some trouble tracking down some odd behaviour with WWW::Mechanize. I am testing a web application. Among other things, I need to generate diffs between a CGI and a newer mod_perl version of the application, to ensure that they behave the same. I am attempting to follow a list of links with the same characteristics from each version of the application, but I am running into an odd problem. I am using code like the following.

use strict; use WWW::Mechanize; my $mech_cgi = WWW::Mechanize->new; my $mech_mod = WWW::Mechanize->new; $mech_cgi->get( 'http://www.foo.com/cgi/' ); $mech_mod->get( 'http://www.foo.com/modperl/' ); my @cgi_links = $mech_cgi->find_all_links( text_regex => qr/Example/ ) +; my @mod_links = $mech_mod->find_all_links( text_regex => qr/Example/ ) +; # test the first ten for( 0..9 ) { print "following link: ", $cgi_links[$_]->url, "\n"; $mech_cgi->follow_link( url => $cgi_links[$_]->url ) or die "Error following link ", $cgi_links[$_]->url; print "following link: ", $mod_links[$_]->url, "\n"; $mech_mod->follow_link( url => $mod_links[$_]->url ) or die "Error following link ", $mod_links[$_]->url; # do some stuff print "finished link $_\n"; }

Everything seems to go fine up to following the first link in the loop. (#0.) After that, when I attempt to follow the second link, my script dies with the error. Unfortunately I haven't yet figured out how to get a more useful error message from WWW::Mechanize. (I'm sure I'm missing something in the docs.)

Here is the output I get:

[mike@localhost ~]$ perl webdiff.pl following link /cgi-bin/m.cgi?mid=261847852 following link /perl/m?mid=261847852 finished link 0 Error following link /cgi-bin/m.cgi?mid=305436842 at webdiff.pl line 9 +1.

I appreciate any help. Thanks.

Update: Formatting error.


In reply to WWW::Mechanize and following multiple links by friedo

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.