http://www.perlmonks.org?node_id=11132410


in reply to Saving HTTP::Cookies into Netscape format using bless/re-bless

You could also use the scan() method to duplicate the stored cookies. It takes a callback which is invoked for each cookie and given arguments in the same order needed for set_cookie()
my $cookie_jar = HTTP::Cookies->new(); # ... my $netscape_cookie_jar = HTTP::Cookies::Netscape->new(); my $callback = sub { $netscape_cookie_jar->set_cookie(@_); }; $cookie_jar->scan( $callback ); $netscape_cookie_jar->save("mycookies.txt");

Replies are listed 'Best First'.
Re^2: Saving HTTP::Cookies into Netscape format using bless/re-bless
by bliako (Monsignor) on May 19, 2021 at 07:32 UTC

    Your approach looks to me to be the safest way for the particular case of cookie-transformation.