Passing Post Params & Object Reference ?

Passing Post Params & Object Reference ?

am 14.10.2007 05:27:22 von unknown

Post removed (X-No-Archive: yes)

Re: Passing Post Params & Object Reference ?

am 14.10.2007 05:52:49 von Gunnar Hjalmarsson

still me wrote:
> I am using LWP to do a POST. I need some help automating the passing
> of parameters and getting the object reference to work.
>
> Here's the (hard coded) version that works fine;
> my $response = $browser->post( $url,['test1'=>'001', 'test2' => 'it
> works']););
>
> What I'd like to do is to set up an array (or hash) with the parameter
> names and values so that I can change the parameters to be passed as
> simply by altering the hash names/values. Then I'd just generate the
> passed parameter string for as many values as are in the array.
>
> Here's a hardcoded sample (no array for simplicity) that I tried as a
> test just to figure out how to get the parameters passed:
>
> my $param1 = "'test1'=>'001',";
> my $param2 = "'test2'=>'002'";
> my $response = $browser->post( $url,[$param1, $param2]);

Try this:

my %params = ( test1 => '001', test2 => '002' );
my $response = $browser->post( $url, [ %params ] );

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Re: Passing Post Params & Object Reference ?

am 15.10.2007 01:48:06 von unknown

Post removed (X-No-Archive: yes)