abg
asked on
perl simple problem/riddle ?
Hi,
This was taken from Matt's Simple Search script
and slightly adapted to match Matt's WWWBoard.
I have tried to add the information "Sorry ! No results found.."
and this is working fine except that I get the phrase
"Sorry ! No results...." printed 3 TIMES on the screen on
3 different lines.
When putting == instead eq the result is the same.
One of the operators like "if" or maybe brackets should
be wrong or misplaced ? Why this phrase is printed 3 times ?
Could you please take a look on this and give me some
tips.
Thanks in advance for your time.
Greetings
Adam
# This routine acts on each file loaded into the @FILES
foreach $FILE (@FILES) {
open(FILE,"$FILE");
@LINES = <FILE>;
close(FILE);
$url = '';
$detail = '';
foreach $line (@LINES) {
if ($line =~ "<TITLE>") {
$lpos = (index($line,"<T") + 7);
$rpos = (rindex($line,"/T"));
$detail = substr($line,$lpos,($rpos- $lpos)-1);
}
if ($line =~ "<title>") {
$lpos = (index($line,"<t") + 7);
$rpos = (rindex($line,"/t"));
$detail = substr($line,$lpos,($rpos- $lpos)-1);
}
if ($line =~ /$FORM{'query'}/i && $line !~ /<html>/i) {
$url = "$FILE";
}
}
elsif ($url ne '') {
print "<LI><a href=\"$url\"><b>$detail</ b></A>\n";
}
if (@LINES eq "0" ) {
print "<B>Sorry ! No results matching your search keyword
!.</B><BR>\n";
}
}
print "</OL><br><hr size=\"1\" width=\"100%\"><form method=POST
action=\"$ENV{'SCRIPT_NAME '}\">\n";
print "<p><center><b>Search by keyword : <input type=text name=\"query\"
size=30> \n";
print "<input type=submit value=\" New search ! \"></form></center>\n";
print "</body></html>";
exit;
__________________________ _______
This was taken from Matt's Simple Search script
and slightly adapted to match Matt's WWWBoard.
I have tried to add the information "Sorry ! No results found.."
and this is working fine except that I get the phrase
"Sorry ! No results...." printed 3 TIMES on the screen on
3 different lines.
When putting == instead eq the result is the same.
One of the operators like "if" or maybe brackets should
be wrong or misplaced ? Why this phrase is printed 3 times ?
Could you please take a look on this and give me some
tips.
Thanks in advance for your time.
Greetings
Adam
# This routine acts on each file loaded into the @FILES
foreach $FILE (@FILES) {
open(FILE,"$FILE");
@LINES = <FILE>;
close(FILE);
$url = '';
$detail = '';
foreach $line (@LINES) {
if ($line =~ "<TITLE>") {
$lpos = (index($line,"<T") + 7);
$rpos = (rindex($line,"/T"));
$detail = substr($line,$lpos,($rpos-
}
if ($line =~ "<title>") {
$lpos = (index($line,"<t") + 7);
$rpos = (rindex($line,"/t"));
$detail = substr($line,$lpos,($rpos-
}
if ($line =~ /$FORM{'query'}/i && $line !~ /<html>/i) {
$url = "$FILE";
}
}
elsif ($url ne '') {
print "<LI><a href=\"$url\"><b>$detail</
}
if (@LINES eq "0" ) {
print "<B>Sorry ! No results matching your search keyword
!.</B><BR>\n";
}
}
print "</OL><br><hr size=\"1\" width=\"100%\"><form method=POST
action=\"$ENV{'SCRIPT_NAME
print "<p><center><b>Search by keyword : <input type=text name=\"query\"
size=30> \n";
print "<input type=submit value=\" New search ! \"></form></center>\n";
print "</body></html>";
exit;
__________________________
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER