I have written the following program. I want to read all the records and test each record for a match, and print it. However, if a match is not found, it should print out no match found at the end of reading the whole file. I get the result each record at a time, but I would like to print no match found if no record is found. Please help.
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI;
$query = new CGI;
use CGI qw(param);
use CGI::Carp qw(fatalsToBrowser);
my $make1 = param("make");
my $model1 = param("model");
my $mile1 = param("mile");
my $year1 = param("year");
my $price1 = param("price");
eval {
open(GUEST, "<car.out") or dienice("Couldn't open auto.out for reading: $! \n");
while (<GUEST>) {
chomp;
($make,$photo,$model,$color,$mile,$eyear,$price=split/\|/;
if ($make1 eq $make) {
if ( $model1 eq $model) {
if($year1 eq $eyear) {
if($price1 le $price) {
if($mile1 le $mile) {
if ($photo eq 'No') {
print "<table width=\"100%\">\n";
print "<tr bgcolor=\"red\"><th>Year</th><th>Make</th><th>Model</th><th>Color</th><th>Miles</th>\n";
print "<th>Price</th><th>E-Mail</th><th>Telephone</th><th>Time-to-Call</th></tr>\n";
print "<td align=\"left\" width=\"50\">$eyear</td><td align=\"left\" width=\"65\"><font color=\"blue\"> $make </font></td><td align=\"left\" width=\"50\">$model</td><td align=\"left\" width=\"50\">$color</td><td align=\"left\" width=\"50\">$mile</td>\n";
print "<td align=\"left\" width=\"50\">$d$price</td><td align=\"left\" width=\"50\"><a href=\"mailto: $email\" >$email </a></td>
<td align=\"left\" width=\"50\">$tele</td><td align=\"left\" width=\"50\"> $time</td>\n";
print "<tr align=\"left\" valign=\"top\" bgcolor=\"#FF99FF\"> <td align=\"left\" colspan=\"7\" >$comment1</td>\n";
print "<td align=\"left\" colspan=\"2\"><font color=\"blue\">CODE#$tele $month-$day-$year</font></td></tr></table>\n";
}
}
}
}
}
else { print "test\n"; }
}
}
}
#if ($yes eq '0' ) { print " Your specified car is not available, please go back and list the whole file\n"; }
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI;
$query = new CGI;
use CGI qw(param);
use CGI::Carp qw(fatalsToBrowser);
my $make1 = param("make");
my $model1 = param("model");
my $mile1 = param("mile");
my $year1 = param("year");
my $price1 = param("price");
eval {
open(GUEST, "<car.out") or dienice("Couldn't open auto.out for reading: $! \n");
while (<GUEST>) {
chomp;
($make,$photo,$model,$color,$mile,$eyear,$price=split/\|/;
if ($make1 eq $make) {
if ( $model1 eq $model) {
if($year1 eq $eyear) {
if($price1 le $price) {
if($mile1 le $mile) {
if ($photo eq 'No') {
print "<table width=\"100%\">\n";
print "<tr bgcolor=\"red\"><th>Year</th><th>Make</th><th>Model</th><th>Color</th><th>Miles</th>\n";
print "<th>Price</th><th>E-Mail</th><th>Telephone</th><th>Time-to-Call</th></tr>\n";
print "<td align=\"left\" width=\"50\">$eyear</td><td align=\"left\" width=\"65\"><font color=\"blue\"> $make </font></td><td align=\"left\" width=\"50\">$model</td><td align=\"left\" width=\"50\">$color</td><td align=\"left\" width=\"50\">$mile</td>\n";
print "<td align=\"left\" width=\"50\">$d$price</td><td align=\"left\" width=\"50\"><a href=\"mailto: $email\" >$email </a></td>
<td align=\"left\" width=\"50\">$tele</td><td align=\"left\" width=\"50\"> $time</td>\n";
print "<tr align=\"left\" valign=\"top\" bgcolor=\"#FF99FF\"> <td align=\"left\" colspan=\"7\" >$comment1</td>\n";
print "<td align=\"left\" colspan=\"2\"><font color=\"blue\">CODE#$tele $month-$day-$year</font></td></tr></table>\n";
}
}
}
}
}
else { print "test\n"; }
}
}
}
#if ($yes eq '0' ) { print " Your specified car is not available, please go back and list the whole file\n"; }