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

#!/usr/bin/perl use URI::URL; use LWP::UserAgent; use HTTP::Request; use HTTP::Request::Common; use HTTP::Request::Form; use HTML::TreeBuilder 3.0; my $ua = LWP::UserAgent->new; my $url = url 'http://www.smsdevice.com/users/sms.php?id=3'; my $res = $ua->request(GET $url); my $tree = HTML::TreeBuilder->new; $tree->parse($res->content); $tree->eof(); my @forms = $tree->find_by_tag_name('FORM'); die "What, no forms in $url?" unless @forms; my $f = HTTP::Request::Form->new($forms[0], $url); $f->field("nr", "+46703123456"); $f->field("msg", "hello world"); my $response = $ua->request($f->press("submit")); print $response->content if $response->is_success;
why wont this work, i just get these lines:
'Can't use an undefined value as an ARRAY reference at /usr/local/lib/perl5/site_perl/5.6.1/HTTP/Request/Form.pm line 103.'
or
'Can't call method "tag" on an undefined value at /usr/local/lib/perl5/site_perl/5.6.1/HTTP/Request/Form.pm line 130.'

Edit Petruchio Sun Nov 18 04:31:53 UTC 2001 - Added markup.

Replies are listed 'Best First'.
Re: im trying to get my perl script to post a CGI query
by hopes (Friar) on Nov 18, 2001 at 08:41 UTC
    First of all, you should use code tags in your posts, so other monks could read (and response them)
    On the other hand
    my $f = HTTP::Request::Form->new($forms<A HREF="/index.pl?node=0&lastn +ode_id=126088">0</A>, $url);
    seem not correct, but I suspect you haven't posted all your code.
    Hopes