
kwatts59
Novice
Dec 12, 2012, 11:43 AM
Post #3 of 5
(1293 views)
|
Re: [FishMonger] Problem with condition statement
[In reply to]
|
Can't Post
|
|
Here is a more extended version of my code. The program is supposed to scan the input file. In the event the program encounters a line containing "***** No hits found *****", the $nohits_pos variable will get set to something other then -1 and while loop should exit. Unfortunately, the program never enters the while loop. $NOHITS = "***** No hits found *****"; $nohits_pos = -1; while ((<INFILE>) && ($nohits_pos lt 0)) { $line = $_; $tagpos = index($line,$TAG); $nohits_pos = index($line,$NOHITS); if ($nohits_pos >= 0) { print OUTFILE "$NOHITS\n"; } elsif ($tagpos >= 0) { $line = <INFILE>; # skip next line $line = <INFILE>; # skip next line $top_hits[$i] = $line; print OUTFILE "$i\t$top_hits[$i]"; while (index($line,">") < 0) { $line = <INFILE>; } print OUTFILE "$i\t$line"; $line = <INFILE>; $int_count = 1; while ((index($line,">") < 0) and (defined $line)) { print OUTFILE "$i\t$line"; $line = <INFILE>; } $nohits_pos = 1; #jump out of file } }
|