Your problem is here:
while (my $line =<FILE>) {
my ($one,$two,$three,$four,$five) = split "\t",$line;
if ($three eq $checkthree) {
print "<p>With matching parameters I should be able to see this
+ </p>";
last;
} else {
print "<p>If I put the else statement in it ignores the fact t
+hat the parameters match - and comes here! (But I don't know why).</
+p>";
last;
}
}
This is what's happening: You're getting to this while statement, and $line gets the first line from the file. You're finding that the first line of the file doesn't match $checkthree, so the else is executed, the line is printed, and the while is exited. To fix this, try some like the following.
my $matched;
while (my $line = <FILE>) {
my ($one,$two,$three,$four,$five) = split "\t",$line;
if ($three eq $checkthree) {
print "<p>With matching parameters I should be able to see thi
+s </p>";
$matched = 1;
last;
}
}
unless ($matched) { # this is like the else
print "<p>If I put the else statement in it ignores the fact that
+the parameters match - and comes here! (But I don't know why).</p>";
}
elusion : http://matt.diephouse.com