use strict; my $ish = $ARGV[0]; open (ISH, "<", $ish) || die "$!"; open (OUT, ">", "out.txt") || die "$!"; { $/ = "//"; while (){ m/DEV_STAGE\t(.*?)\n/g; my $a= $1; my $b; if (m/PREDICTED_GENE\t(.*?)\n/g){ $b= $1; } else{ $b = '#'; } while (m/\tSTAINED_REGION:\t(.*?)\tSTAINED_MOL:\t(.*?)\n/g) { my $c = $1; my $x = $2; print OUT "$b\t$a\t$c\t$x\n"; } } }