Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi - thanks for checking my code. This code worked for you? I copied exactly what you posted (well, I changed $mech->submit_form to $mech_obj->submit_form) and I still got the same error:

Unexpected field value http://search.cpan.org at (eval 5) line 1

It sounds like there is something else going on at my end. I'll have to keep digging. Thanks again for checking this out for me.

Update: I added use Carp 'verbose' to the test script and got this:

Unexpected field value http://search.cpan.org at C:/ActivePerl/site/li +b/HTTP/Headers.pm line 256 HTTP::Headers::_header('HTTP::Headers=HASH(0x2249820)', 'Referer', 'ht +tp://search.cpan.org') called at C:/ActivePerl/site/lib/HTTP/Headers +.pm line 150 (etc)

The error is coming from the _header subroutine in HTTP::Headers. The code in question is this:

if (!ref($val)) { push(@new, $val); } elsif (ref($val) eq 'ARRAY') { push(@new, @$val); } else { Carp::croak("Unexpected field value $val"); }

I added a Data::Dumper print statement to determine what $val was, and I got the following:

$VAR1 = bless( do{\(my $o = 'http://search.cpan.org')}, 'URI::http' );
which matches the "action" value in the $mech_obj above. The _header routine seems to want scalars (or a ref to an array), but it looks like it's getting a hash ref (or is it the whole object?) from the WWW::Mechanize object instead.

I was not sure how to proceed, so emailed the authors of those modules. Additional suggestions are welcome. (Incidently, now that I know more about the error, I found a previous report of it in HTTP::Message.)


In reply to Re^2: "Unexpected field value" error from HTTP::Headers when using WWW::Mechanize by bobf
in thread "Unexpected field value" error with WWW::Mechanize by bobf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-24 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found