Using GET in a loop

Using GET in a loop

am 17.09.2004 10:56:57 von A.K.Warntjen

------=_NextPart_000_000E_01C49C9C.AB888A60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I am experiencing problems when working with GET in a loop.=20

I want to retrieve information from a number of pages that all have the =
same structure. Thus, I would like to use a retrieve them via GET and =
process their information in a loop. However, GET seems to store the =
information in a hidden variable and appends it. Instead of replacing =
the content of my "temporary" variable the content of the new website is =
appended to the content of all previously retrieved ones. Thus, my =
information processing (getting various information from the "temporary" =
content variable and assigning it to other variables) always yields the =
same results, the one from the first website retrieved. Because I rely =
on the structure of the website to identify the necessary bits and =
pieces of information, I need the content variable to be replaced =
everytime.

I already tried global and local variables. Furthermore, I "empty" the =
content variable every time prior to retrieving a new site. None of this =
works. I thought about having one content variable per site (e.g., =
$content1, $content2, ...), but this isn't very efficient, is not very =
much in the spirit of variables and I wouldn't know how to automatically =
generate a new variable for each round of the loop (if that is possible) =
anyway.=20

Here is the (abbreviated) code:=20


use LWP::Simple;
foreach $ID (@ID) {
$content=3D" ";
$url=3D"http:://...docid=3D$ID";
$content=3Dget($url);
# subsequently I extract information from the string =20
# $content, which only serves as a contemporary storage=20
Open FILE, ">> C:/perl/output.txt"
Print FILE $content;=20
# actually it's all the other variables whose values I=20
# want to save
}


Any help would be greatly appreciated!
Best,

Andreas
__________________________

Andreas Warntjen
LSE Butler's Wharf
11, Gainsford Street
London , SE1 2NE
United Kingdom

http://personal.lse.ac.uk/warntjen
Phone: +44 (0)870 036 6666, ext. 2985
------=_NextPart_000_000E_01C49C9C.AB888A60--

Re: Using GET in a loop

am 17.09.2004 12:44:58 von davem

On Fri, Sep 17, 2004 at 09:56:57AM +0100, Andreas Warntjen (LSE) wrote:
> Hi,
>
> I am experiencing problems when working with GET in a loop.

I believe this has been answered for you on Perl Monks.

Dave.

--
A power surge on the Bridge is rapidly and correctly diagnosed as a faulty
capacitor by the highly-trained and competent engineering staff.
-- Things That Never Happen in "Star Trek" #9