You are very close to having what you want. The following slightly modified version of your program may help.
#!/usr/bin/perl use warnings; use strict; { my $gi = ""; while (<DATA>) { chomp($_); $_ =~ s/\(|\)//xmg; if ( $_ =~ /LOCUS\s+(\S+)/ ) { $gi = $1; } elsif ( $_ =~ /\A\s+(\w+)\s+(\S+)\.\.(\S+)/ ) { print "\n\t\t$gi\t$1\t$2\t$3"; } elsif ( $_ =~ /gene\=\"(\S+)\"/ ) { print "\tgene=$1"; } elsif ( $_ =~ /\/transcript_id\=\"(\S+)\"/ ) { print "\tTranscriptID=$1"; } } print "\n"; } __DATA__ gene 348634..348822 /gene="LOC100129305" /note="Derived by automated computational analysi +s using gene prediction method: GNOMON. Supporting eviden +ce includes similarity to: 1 Protein" /db_xref="GeneID:100129305" mRNA 348634..348822 /gene="LOC100129305" /product="similar to C21orf94 protein" /note="Derived by automated computational analysi +s using gene prediction method: GNOMON. Supporting eviden +ce includes similarity to: 1 Protein" /transcript_id="XM_001714760.1" /db_xref="GI:169215265" /db_xref="GeneID:100129305"
This produces
gene 348634 348822 gene=LOC100129305 mRNA 348634 348822 gene=LOC100129305 + TranscriptID=XM_001714760.1
update: removed the setting of $\ as it is not necessary.
update2: I used perltidy to reformat your program. You might like to give it a try.
In reply to Re: File Parsing issue
by ig
in thread File Parsing issue
by cowboyrocks
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |