Hi,

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

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. 

Here is the (abbreviated) code: 

<code>
use LWP::Simple;
foreach $ID (@ID) {
 $content=" ";
 $url="http:://...docid=$ID";
 $content=get($url);
 # subsequently I extract information from the string  
 # $content, which only serves as a contemporary storage 
 Open FILE, ">> C:/perl/output.txt"
 Print FILE $content; 
 # actually it's all the other variables whose values I 
 # 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

Reply via email to