Few days a go, I asked about reading the content of a xml tag without the use of XML::Parser, and other modules. Today while fumbling around I wrote a code on how to read the content of specific tags and I thought I should share it.
open(DBASE, $path."database.txt") || die ("File does not exist, $!\n") +; while(<DBASE>) { chomp; print (LIST "\nTIME: ".localtime(time)."\n"); print (LIST "$_\n\n"); open (XFILE, $_) || die ("Can\'t open[$_], $!\n"); while(<XFILE>) { chomp; if($_ =~ /\<name\>/../\<\/name\>/) { print (LIST "$_\n"); } elsif($_ =~ /\<keywords\>/../\<\/keywords\>/) { print (LIST "$_\n"); } elsif($_ =~ /\<description\>/../\<\/description\>/) { print (LIST "$_\n"); } elsif($_ =~ /\<results\>/../\<\/results\>/) { print (LIST "$_\n"); } }close XFILE; } close LIST; close DBASE;
The above code is working find but if any monks could help me make it smarter, I will really appreciate it.
Thanks,
Edman
In reply to Reading b/w tags by gzayzay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |