HTTP-404 has asked for the wisdom of the Perl Monks concerning the following question:

Hello guys, Thank You everyone who helped me in my last node I have following code
$ua = new LWP::UserAgent; $ua->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5. +12  [en]' . $ua->agent); $ua->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5. +12  [en]'); $req = HTTP::Request->new(GET => 'http://www.chollonet.com/trucoteca/ +truco.php?idjuego=598&plataforma=4'); print "$id\n"; $html=$ua->request($req)->as_string;
Withou loop it works just fine, but when i make loop like this
$ua = new LWP::UserAgent; $ua->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5. +12 [en]' . $ua->agent); $ua->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5. +12 [en]'); $req = HTTP::Request->new(GET => 'http://www.chollonet.com/trucoteca/ +truco.php?idjuego=$id&plataforma=4'); #<-----JUST USE $ID insted of +number print "$id\n"; $html=$ua->request($req)->as_string;
I get HTTP-400 bad request. How can I make loop with LWP, then? Thank You very much in advance

Replies are listed 'Best First'.
(bbfu) Re: Batch web fetch scipt
by bbfu (Curate) on Jul 29, 2001 at 23:48 UTC

    You're using single quote strings which don't interpolate. So the request you end up actually sending is:

    http://www.chollonet.com/trucoteca/truco.php?idjuego=$id&plataforma=4

    and not

    http://www.chollonet.com/trucoteca/truco.php?idjuego=<whatever-$id-held>&plataforma=4

    HTH.

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.

Re: Batch web fetch scipt
by mitd (Curate) on Jul 29, 2001 at 23:51 UTC

    Your problem is here:

    ...'http://www.chollonet.com/trucoteca/ +truco.php?idjuego=$id&plataforma=4')

    Single quotes! $id is not being interpolated. :)

    mitd-Made in the Dark
    'My favourite colour appears to be grey.'