while (<>) { $foundit = 0; chomp; $input=$_; if($input =~ /what is/i or $input =~ /who is/i or $input =~ /tell me about/i){ $input =~ s/what is//ig; $input =~ s/who is//ig; $input =~ s/tell me about//ig; $input =~ s/\?//g; $input =~ s/a //i; ($part1, $part2, $part3) = split " ", $input; open (FILEHANDLE, ") { if($_ =~ /$input/i or $_ =~ /<title>$part1 $part2/i or $_ =~ /<title>$part2 $part3/i or $_ =~ /<title>$part1/i or $_ =~ /<title>$part2/i or $_ =~ /<title>$part3/i and $correct == 0){ $correct = 1; }else{ continue; } if($_=~ /<p>/i and $foundit == 0){ $foundit = 1; $test = $_; last; } } close FILEHANDLE; ($crap,@goodstuff) = split ">", $test; foreach $item (@goodstuff) { ($finalgoodstuff,$crap)=split "<",$item; $beststuff .= $finalgoodstuff; } print "\n"; print"$beststuff"; print "\n"; $beststuff = ""; $finalgoodstuff = ""; } }