gzayzay has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Reading b/w tags
by mickeyn (Priest) on Mar 21, 2006 at 07:46 UTC | |
by Anonymous Monk on Mar 21, 2006 at 13:06 UTC |