Hi all,

I,ve got a problem. Following Code reads an Example-String in XML-Style, filters out the necessary information and writes it in a HASH. Now I want to read a file and not only one String. I thought that I can just put a while-loop around my code but that don't work. How may I solve that.


#######################
#!/usr/bin/perl
$text = '<energietraeger>Erdoel</energietraeger> <umwandlung>Verbrennung</umwandlung>';
$tmp = $text;
while($tmp =~ /<[^\>]+\>/){
$tmp =~ s/<([^\>]+)\>([^<]+)<\/[^\>]+\>//;
$werte{$1} = $2;
}
foreach $key(keys(%werte))
{
print $key." - ".$werte{$key}."\n";
}
#######################

what i get out is:

energietraeger - Erdoel umwandlung - Verbrennung
what I tried:

open (FILE, "<test.xml");
while($text = <FILE>)
{ ##CODE ABOVE## }

then nothing happends

thanks for every advice
Sorin


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to