views:

47

answers:

2

I'm getting a Can't use an undefined value as a HASH reference error trying to call HTTP::Message::decodable() using Perl 5.10 / libwww installed on Debian Lenny OS using the aptitude package manager. I'm really stuck so would appreciate some help please.

Here's the error:

 Can't use an undefined value as a HASH reference at (eval 2) line 1.
at test.pl line 4
main::__ANON__('Can\'t use an undefined value as a HASH reference at 
enter code here`(eval 2)...') called at (eval 2) line 1
HTTP::Message::__ANON__() called at test.pl line 6

Here's the code:

use strict;
use HTTP::Request::Common;
use Carp;
$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };

print HTTP::Message::decodable();
+1  A: 

Looking at the changelog, it looks like HTTP::Message::decodable() was added in version 5.814. Are you sure you are reading the right documentation for your version?

Try:

perl -MHTTP::Message -e 'warn $HTTP::Message::VERSION'

.. it should return 5.814 or more...

Gavin Brock
Thanks! I'm obviously not on the right version.$ perl -MHTTP::Message -e 'warn $HTTP::Message::VERSION'5.812 at -e line 1.If I look in aptitude it says the libwww-perl package is on version 5.813-1 (I'm not sure why this is different to 5.812 given by the command above). Looks like I need to upgrade
scarba05
+1  A: 

Gavin was right - I had an old version of libwww-perl installed. I was relying on using the latest version available on Debian Lenny (assuming this was fairly up to date). Turns out the latest version available is 5.813 but I need 5.814 or more to use this function. As there's no packaged version available via aptitude I installed the latest using CPAN instead:

$ perl -MCPAN -e shell
cpan[1]> upgrade HTTP::Message

All done!

scarba05
Don't post non-answers as answers. Use comments instead or update the question if you have additional information.
Sinan Ünür
This looks like an answer to me. It explains the problem and provides a solution.
brian d foy
@brian and it looks to me like it should have been a comment to @Gavin's answer.
Sinan Ünür