Good day everyone, I have several questions concerning Mechanize. I’ve tried my best, but a lack of… hmm… time forces me to ask someone smarter. So:

1. Is there a way to close/kill/unload an LWP::UserAgent object? If not, maybe there is a way to reset it? I’ve tried to make a new UA under the same name, tried emptying a cooky_jar, but something stays in memory anyway.

2. Actually I’m trying to make a script that uses Mechanize for logic and sockets for transport, so I use $mech->_update_page($request, $response) which updates all the info, except $mech->uri, for some reason, although $mech->base works fine. Is there a way to update it with a base value?

3. I’m using a “$request = $form->make_request; $mech->_make_request( $request ); $mech->_modify_request( $request );” sequence to take a request from Mechanize and send it to sockets (then I take their response, and return and “_update_page($request, $response)” it back to Mech). Question: is there a “normal” way to catch/borrow a request from standard Mech function ($mech->submit_form( ... ), $mech->follow_link(...), redirect etc.) before it executes it, and then block it?

I’ll appreciate any help :) thanks.

In reply to Mechanize questions (not very obvious) by wandererer

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.