my $in_comment = undef; while( ) { my @fld = split /\|/, $_; do { $in_comment = 1; next } if $fld[5] =~ m{ /\* }x; do { $in_comment = undef; next } if $fld[5] =~ m{ \*/ }x; print "$fld[0] $fld[2] sequence=$fld[4] $fld[5]" if /$regex/ and not $in_comment; }