Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

LWP post method, mutliple parameters

by davidov0009 (Scribe)
on Dec 22, 2007 at 21:05 UTC ( [id://658704]=perlquestion: print w/replies, xml ) Need Help??

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

By looking at the following from the documentation of the LWP::UserAgent module:
"$ua->post( $url, \%form, $field_name => $value, ... )"
it seems to me that I can pass BOTH a hashref AND a list of name value pairs to the SAME form. Is that correct?

I am currently trying something like this:

$response = $browser->post( 'http://site.com/form.php', \%form, 'val1' => 1, 'val2' => 0, @header);

This, however, doesn't seem to work. Any ideas?


use strict; use CGI;

Replies are listed 'Best First'.
Re: LWP post method, mutliple parameters
by merlyn (Sage) on Dec 22, 2007 at 21:52 UTC
    Those are for headers, not form params. They'll show up as "val1: 1" in the post header, which you would see if you checked $ENV{HTTP_VAL1} in the form processor, for example.
      So I'd have to throw all those into the hashref before sending it off via post()? Any better way to do this? I have a subroutine that strips form parameters from source html and returns them as a hash. I want to add more set parameters to that hash and then send them off as a post.

      use strict; use CGI;
        What was in place before was
        $ua->post( $url, [ name => value, name => value ], @header)
        Would it be the same to replace the [ name => value...] with a hashref?

        use strict; use CGI;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://658704]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found