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

Esteemed monks, i require your assistance.
I have written a perl program which uses WWW::Mechanize. I am using a "post" method. But while executing i am getting the following error.
The piece of code that it points to
$request =POST "http://www.abc.com/ChooseZone.aspx?type=A" , [ '__EVENTTARGET' => "rdlZone_0", '__EVENTARGUMENT' => "", '__VIEWSTATE' => "dDw0NzUyOTE0NzQ7", 'rdlZone' => "1", ] ;
The error is as below
String found where operator expected at stats.plx line 18, near "POST +"http://www.abc.com/ChooseZone.aspx?type=A"" (Do you need to predeclare POST?) syntax error at stats.plx line 18, near "POST "http://www.abc.com/Choo +seZone.aspx?type=A""
Please assist
Note: the code was generated by a javascript monitoring proxy program
UPDATE: PROBLEM SOLVED

Replies are listed 'Best First'.
Re: WWW::Mechanize Post Method - Help find error
by Corion (Patriarch) on May 18, 2004 at 05:59 UTC

    I'm not sure what "javascript monitoring proxy program" you are using, but the output does not look like valid Perl.

    Maybe you meant the HTTP::Request constructor method POST, but you don't show any more relevant code. Check the top of your script for a line like use HTTP::Request;. And even then, the generated line should look more like :

    $request = HTTP::Request->new( POST => ... );

    So to me, it seems like your "javascript monitoring proxy program" doesn't really produce direct Perl code.

      Thank you for your help, i located the error.
      The code
      $request = new HTTP::Request(POST "http://www.abc.com/ChooseZone.aspx? +type=A" , [ '__EVENTTARGET' => "rdlZone_0", '__EVENTARGUMENT' => "", '__VIEWSTATE' => "dDw0NzUyO", 'rdlZone' => "1", ] );
      has been changed to
      $request = new HTTP::Request('POST'=> "http://www.abc.com/ChooseZone.a +spx? +type=A" , [ '__EVENTTARGET' => "rdlZone_0", '__EVENTARGUMENT' => "", '__VIEWSTATE' => "dDw0NzUyO", 'rdlZone' => "1", ] );
      It was a matter of changing POST to 'POST'=>
      Thank you for your help
        It was a matter of changing POST to 'POST'=>

        For future reference, note that the => operator is just like the comma, except it does automagic quoting of its left-hand-side. This is made exactly for the case you've shown, to eliminate the need for quoting. In other words, your line could be written as:

        $request = new HTTP::Request(POST => "...", [ __EVENTTARGET => "rdlZone_0", __EVENTARGUMENT => "", __VIEWSTATE => "dDw0NzUyO", rdlZone => "1", ] );