use strict; use WWW::Mechanize; use YAML qw(DumpFile LoadFile freeze thaw); # init a mech instance my $mech = WWW::Mechanize->new(); # on first instance... if(! -f 'stored_mech.dat') { # get, freeze, and store $mech->get('http://localhost/mech-form.php'); DumpFile('stored_mech.dat', [freeze($mech)]); exit; } # on subsequent instance... else { # retrieve, thaw, and submit form my $stored = LoadFile('stored_mech.dat'); $mech = thaw($stored->[0]); $mech->submit_form(form_number=>1); }