Tutorial :Amazing error in perl [closed]



Question:

i write this perl code :

use HTTP::Request::Common qw(POST);  use LWP::UserAgent;  my $ua = LWP::UserAgent->new();  my $req = POST 'http://example.com',  [ hfc /[pos]/ => 'yayaya' ];  $content = $ua->request($req)->as_string;   

but when i compile it i get this error :

syntax error at C:\Documents and Settings\ysys\ya.pl line 5, near "/ =>"  

what am i going to do ? Thanks in Advance .


Solution:1

I think this is what she wants:

use LWP::UserAgent;   my $ua = new LWP::UserAgent;    #this should work  my $response = $ua->post('http://www.example.com', ["hfc[pos]" => 'yayaya']);      my $content = $response->content;   

This is how you use post(): $ua->post( $url, $field_name => $value,...)

By the way when you read documentation and it says something like:

$ua->request($request, $arg [, $size])  

It just means that the $size argument is optional. You must NOT include the brackets [ ] in your code.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »