Er, did you read the POD for HTTP::Cookies? I think you'll have to clear that cookie and put it back in the right way; i.e., not as a string but as an array of elements. That said, this turns out to not be so trivial as none of the cookie modules seems to parse strings correctly...? So unless someone has something more terse, this is what I'd do-

use WWW::Mechanize; use HTTP::Cookies; my $mech = WWW::Mechanize->new(); my $cookie_jar = HTTP::Cookies->new( autosave => 1, file => "/your/cookies.txt" ); # $cookie_jar->clear(); $mech->cookie_jar($cookie_jar); $mech->agent_alias('Windows IE 6'); $mech->get("http://www.amazon.com"); my $self_enclosed_callback = sub { my ( $version, $key, $val, $path, $domain, $port, $path_spec, $secure, $expires, $discard, $extra ) = @_; # Remove the currently iterating cookie from the jar. # NB: this might be dangerous! Seems to work though. $cookie_jar->clear( $domain, $path, $key ); # Now change domain, just for example. $domain =~ s/\.com\z/.org/; $cookie_jar->set_cookie( $version, $key, $val, $path, $domain, $port, $path_spec, $secure, $expires, $discard, $extra ); }; # Before our callback. print $cookie_jar->as_string, "\n"; $cookie_jar->scan( $self_enclosed_callback ); # After our callback. print $cookie_jar->as_string, "\n";

In reply to Re^3: Mechanize cookie jar update? by Your Mother
in thread Mechanize cookie jar update? by Anonymous Monk

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.