By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,971 Members | 900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,971 IT Pros & Developers. It's quick & easy.

use HTTP::Request::Common Problem when Updating with String

P: n/a
Hello All,
I want to update a form using the LWP & HTTP method. It was
working fine when I am updating the values like this

$ua = LWP::UserAgent->new;
$url ='http://xxx.be/cgi-bin/viewauth/Tracking/TestProjectAgainInitialDevStory#edittable2';
use HTTP::Request::Common;

my $res = $ua->request(POST $url,
Content_Type =>'form-data',
Content => [
ettablenr => '2',
etcell2x1 =>'Task',
etcell2x2 =>'2',
etcell2x3 =>'3',
etcell2x4 =>'4',
etcell2x5 =>'High',
etcell2x6 =>'SureshC',
etcell2x7 =>'CSuresh',
etcell2x8 =>'Twiki Data Updation',
etrows => '2',
etsave =>'Save table']);
It was not working when I store the value into a Variable. Like This.

$postStr = ettablenr => '2', etcell2x1 =>'Task', etcell2x2 =>'2',
etcell2x3 =>'3', etcell2x4 =>'4', etcell2x5 =>'High', etcell2x6
=>'SureshC', etcell2x7 =>'CSuresh', etcell2x8 =>'Twiki Data
Updation', etrows => '2', etsave =>'Save table']);

$ua = LWP::UserAgent->new;
my $res = $ua->request(POST $url, Content_Type=>'form-data', Content
=>[$postStr]);

Can any one pls let me know what is the problem when i doing like
this.
Thanks in Advance
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <ab**************************@posting.google.com >, Sure
<cs*******@yahoo.com> wrote:
Hello All,
I want to update a form using the LWP & HTTP method. It was
working fine when I am updating the values like this
Disclaimer: I have not used LWP, but I can see a possible problem with
your code.

$ua = LWP::UserAgent->new;
$url
='http://xxx.be/cgi-bin/viewauth/Tracking/TestProjectAgainInitialDevStory#edit
table2';
use HTTP::Request::Common;

my $res = $ua->request(POST $url,
Content_Type =>'form-data',
Content => [
ettablenr => '2',
etcell2x1 =>'Task',
etcell2x2 =>'2',
etcell2x3 =>'3',
etcell2x4 =>'4',
etcell2x5 =>'High',
etcell2x6 =>'SureshC',
etcell2x7 =>'CSuresh',
etcell2x8 =>'Twiki Data Updation',
etrows => '2',
etsave =>'Save table']);
So request() expects a reference to an array following Content.


It was not working when I store the value into a Variable. Like This.

$postStr = ettablenr => '2', etcell2x1 =>'Task', etcell2x2 =>'2',
etcell2x3 =>'3', etcell2x4 =>'4', etcell2x5 =>'High', etcell2x6
=>'SureshC', etcell2x7 =>'CSuresh', etcell2x8 =>'Twiki Data
Updation', etrows => '2', etsave =>'Save table']);
This contains a syntax error and will not compile. I presume you mean
$postStr = [ ... ];

$postStr is a scalar variable containing a reference to an anonymous
array. Please cut-and-paste code rather than retyping it.

$ua = LWP::UserAgent->new;
my $res = $ua->request(POST $url, Content_Type=>'form-data', Content
=>[$postStr]);


You are passing Content => [ $postStr ] to request(). In other words,
you are passing a reference to an anonymous array with one element: a
reference to an anonymous array. You have one too many levels of
reference. Try changing this to: Content => $postStr
FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.