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

Discussion in 'Perl' started by Sure, Sep 1, 2004.

  1. Sure

    Sure Guest

    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
     
    Sure, Sep 1, 2004
    #1
    1. Advertising

  2. Sure

    Jim Gibson Guest

    In article <>, Sure
    <> 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.
     
    Jim Gibson, Sep 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denny
    Replies:
    1
    Views:
    791
  2. Some Guy

    need help with HTTP::Request::Common

    Some Guy, Mar 12, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    337
    Tad McClellan
    Mar 13, 2005
  3. Replies:
    9
    Views:
    268
    Charles DeRykus
    Mar 14, 2006
  4. Alex
    Replies:
    1
    Views:
    172
    Gunnar Hjalmarsson
    Mar 20, 2006
  5. Replies:
    1
    Views:
    226
    zentara
    Nov 6, 2006
Loading...

Share This Page