in reply to while loop logic
It looks to me as though you've got your 'resume' condition (the fifth field has an end-comment marker) inside the condition wherein you detect a start marker. This means that you'll only skip the first line after a start marker. I don't see a straightforward way to avoid checking the fifth field every iteration.
How 'bout something like this (untested):
my $skip = 0; LOOP: while ($line = <CMDTXTF>) { @fld = split /\|/,$line; if ($fld[5] =~ / \*\//) { $skip = 0; # you found an end-comment, turn skipping off for the next line next LOOP; } if ($fld[5] =~ /\/\*/) { $skip = 1; # you found a start-comment, turn skipping on next LOOP; } unless ($skip) { print "$fld[0] $fld[2] sequence=$fld[4] $fld[5]" if $line =~ /$re +gexp/; } }
|
|---|