my $Gene='ds_chY.xml'; my $filename = 'ID.txt'; my $ID; my $subSnpClass; open(my $fh, '>', $filename) or die "Could not open file '$filename' $!"; print $fh "RS_SNPs\tsubSnpClass"; open(GTFFILE, $Gene) or die ("Cannot open the file"); while(){ $_=~ s/^\s+//; if ($_= ~/ssId=\s*?(\S+)/) { $ID=$1; $ID =~ s/"//; chop $ID; print $fh "$ID\n"; } if ($_= ~/subSnpClass=\s*?(\S+)/) { $subSnpClass=$1; $subSnpClass =~ s/"//; chop $subSnpClass; print $fh "\t$subSnpClass\n"; } }