
PGScooter
stranger
Mar 25, 2001, 2:02 PM
Post #1 of 1
(148 views)
|
I'm not sure whether this belongs in the intermediate or beginner so please move it if it belongs elsewhere. I can not fiugre out what I am doing wrong with the script! It retrieves the html code great and posts it with just one slight problem, the last word on each definition is always missing. The code first gets the html code... then extracts the lines that begin with "<Li> and then removes the tags, and then writes each definition to OUTPUT... Any ideas? thankyou pl file: use LWP::Simple; use HTML::Parse; use HTML::FormatText; $VocabList='<vocablist.txt'; open(INFILE,$VocabList) or die "The txt file could not be found.\n"; $List=<INFILE>; @words=split(/ /,$List); open(OUTPUT,'>output.txt'); foreach $i(@words) { $definition=get("http://www.dictionary.com/cgi-bin/dict.pl?term=$i"); print OUTPUT "\n\n$i\n\n\t"; @lines = split(/\n/,$definition); foreach $line (@lines) { if($line=~/^<LI>/) { $stripped = HTML::FormatText->new->format(parse_html($line)); print OUTPUT "$stripped\n\t"; } } }
|