in reply to while loop logic

You could use a flag.
my $comment; while ($line = <CMDTXTF>) { @fld = split /\|/,$line; $comment++, next if $fld[5] =~ /\/\*/; $comment--, next if $fld[5] =~ / \*\//; next if $comment; print "$fld[0] $fld[2] sequence=$fld[4] $fld[5]" if $line =~ /$rege +xp/; }