bennetthaselton has asked for the wisdom of the Perl Monks concerning the following question:

This looks like a newbie question but I've been using other methods of this class for 10 years without seeing this problem, so I don't know what's going wrong.

I have HTTP::Cookies version 6.01 installed, perl 5.16.3, CentOS 7.1. When I try to call the get_cookies() function:

perl -e 'use HTTP::Cookies; $x = new HTTP::Cookies; $x->get_cookies("foo.com");'

I get:

Can't locate object method "get_cookies" via package "HTTP::Cookies" at -e line 1.

But the HTTP::Cookies documentation clearly says it's a member method:
http://search.cpan.org/~oalders/HTTP-Cookies-6.04/lib/HTTP/Cookies.pm
$cookie_jar->get_cookies( $url_or_domain )
Calling it on a new instance, I would expect it to return undef, not to give an error message that this is not a member method of the class.

Now, that's the documentation for version 6.04 and I am using 6.01. But it seems hard to believe that such a basic function like get_cookies() would have been missing from version 6.01. Am I doing something wrong?

I can call the as_string() method (which does work) and parse it for the cookie that I'm looking for, but I would still like to know why get_cookies() isn't working.
  • Comment on "Can't locate object method get_cookies" but it's a method of HTTP::Cookies;

Replies are listed 'Best First'.
Re: "Can't locate object method get_cookies" but it's a method of HTTP::Cookies;
by kcott (Archbishop) on Jun 11, 2018 at 03:19 UTC

    G'day bennetthaselton,

    "... that's the documentation for version 6.04 and I am using 6.01. But it seems hard to believe that such a basic function like get_cookies() would have been missing from version 6.01."

    And yet it's true! If you take a look in the Changes file, you'll see it was introduced in version 6.02.

    — Ken

Re: "Can't locate object method get_cookies" but it's a method of HTTP::Cookies;
by Athanasius (Archbishop) on Jun 11, 2018 at 03:04 UTC

    Hello bennetthaselton,

    Now, that's the documentation for version 6.04 and I am using 6.01. But it seems hard to believe that such a basic function like get_cookies() would have been missing from version 6.01.

    But the documentation shows that it was indeed missing:

    Why not simply update to the latest version?

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,