Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > use HTTP::Request::Common Problem when Updating with String

Reply
Thread Tools

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

 
 
Sure
Guest
Posts: n/a
 
      09-01-2004
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
 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      09-02-2004
In article <(E-Mail Removed) >, Sure
<(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating JTable Atomically - block data changes while updating. news.rcn.com Java 2 12-10-2007 11:49 AM
Updating Eclipse to use Webtools failing? usenet.junk.000@gmail.com Java 2 09-11-2006 12:42 AM
updating query string on client Dennis ASP .Net 5 08-18-2006 09:57 AM
Updating DTD to agree with its use in doc's christopher.c.brewster@lmco.com XML 5 01-26-2005 10:21 PM
updating software to use a different drive yellow submarineİ Computer Support 5 10-04-2003 06:22 AM



Advertisments