in reply to Sorry message
An easy way to do what you want is to add another variable, and if a match is found put a 1 in it. At the end of your script if the variable == 0 then print your sorry message.#!/usr/bin/perl5 require "get_form_data.pl"; &get_form_data(); $search_term = $FORM{'search'}; print "Content-type: text/html\n\n"; opendir(DIR, "."); while($file = readdir(DIR)) { next if($file !~ /.html/); open(FILE, $file); $found_match = 0; $title = ""; while() { if(/$search_term/i) { $found_match = 1; } if((//) || ($found_title)) { if((/<\/TITLE>/) && (//)) { chop; $title = $_; $title =~ s///g; $title =~ s/<\/TITLE>//g; } else { if($found_title == 1) { $title = $_; $found_title = 2 } elsif($found_title == 2) { $found_title = 0; } else { $found_title = 1; } } } } if($found_match) { print "<A HREF=\"$file\">$title</A>\n"; print "<BR>\n"; } close(FILE); } closedir(DIR); exit;
|
|---|