in reply to HTTP::Message

The _headers object is of class HTTP::Headers. If you look in that class you will find that your error message comes from the _header method. That message would be much more informative if it included the field name, but oh well.

To debug further I would suggest adding to your script the line:

use Carp 'verbose';
That won't fix anything, but it will give you a complete stack backtrace into your code, and you can figure out what is going on from there.

PS: There is discussion at Are debuggers good? both pro and con on using debuggers for debugging. You might find it an interesting read.