This code works OK, even if I change it to use Mechanize instead of UserAgent, but does not work inside my original program... remove_handler() removes all available handlers, including the internal, ignoring %matchspec.

print "Hdl1: ".join(" ",$mech->handlers('response_header', $mech->re +sponse()))."\n"; $mech->add_handler(response_header => \&response, owner => "vitoco") +; print "Hdl2: ".join(" ",$mech->handlers('response_header', $mech->re +sponse()))."\n"; $mech->add_header('If-Modified-Since', time2str($current)) if $curre +nt; my $resp = $mech->get($url, ':content_file' => "$file.tmp"); $mech->delete_header('If-Modified-Since') if $current; $mech->remove_handler('response_header', owner => "vitoco"); print "Hdl3: ".join(" ",$mech->handlers('response_header', $mech->re +sponse()))."\n"; print "Hdl4: ".join(" ",$mech->handlers('response_header', $resp))." +\n";
Hdl1: HASH(0x1f87dbc) Hdl2: HASH(0x1f87dbc) HASH(0x1f9d174) Hdl3: Hdl4:

I changed de example to use :content_file, and stil works, so it is not that. Note that Hdl3 and Hdl4 uses different response objects (or the same, obtained from different ways).


In reply to Re^4: LWP handlers examples? by vitoco
in thread LWP handlers examples? by vitoco

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.