#!/usr/bin/perl use strict; use warnings; my %info = ('gi' => "", 'version' => "", 'cds' => ""); # here we collect all information sub flush_info { # print out all information: print "$info{gi}"."\t"."$info{version}"."\t"."$info{cds}\n"; %info = (); }; my $data = '/DATA/GenBankFile.gb'; # GenBank file is located at C:\DATA open (INFILE, '<', $data) or die "Cannot!\n"; while () { last if m!//$!; if (m!^VERSION.*\w:(\d+)! ) { $info{version} = $1; } elsif (m!GI:(\d+)!) { if ($info{cds}) { # we are in a CDS block $info{gi} = $1; }; } elsif (m!^\s+CDS\s+(.*)!) { # a new gene information has started flush_info(); # now remember the CDS $info{cds} = $1; } else {warn "Ignoring unknown line [$_]\n";}; }; # Output any leftover information: flush_info();