I would tend to propose that you extend WWW::Mechanize to support having multiple browser sessions.

package WWW::Mechanize::Clones; use strict; use warnings; use Storable 'dclone'; sub WWW::Mechanize::clone { dclone $_[0] } __END__ =head1 NAME WWW::Mechanize::Clones - "fork" browser windows =head1 DESCRIPTION This allows you to "fork" a WWW::Mechanize browser so you can follow m +ultiple links. =head1 SYNOPSIS use WWW::Mechanize; use WWW::Mechanize::Clones; my $browser = WWW::Mechanize->get( ... ); my @browsers = map( { my $new_browser = $browser->clone; $new_browser->follow_link( $_ ); } $browser->find_all_links( ... ) ); =head1 ADDED METHODS =over 4 =item $browser->clone This additional method is added to the WWW::Mechanize class so that yo +u can make a copy of your browser at a point in time. This allows you + to follow multiple links from the same page without having to back t +rack. Here is an example of how to do this without this module: $browser->follow_link( ... ); # do some work $browser->back; $browser->follow_link( ... ); And here is how you can how do this. You no longer have to keep track +of how many times to use ->back to get back to where you can follow t +he other link. my $new_browser = $browser->clone; $browser->follow_link( ... ); $new_browser->follow_link( ... ); =back =cut

In reply to Re: WWW::Mechanize and following multiple links ( use WWW::Mechanize::Clones) by diotalevi
in thread 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.