in reply to Re^6: Read, match string and print
in thread Read, match string and print
It's not that hard. The process basically is:
my %info; # here we collect all information # The name and order of the columns we want to print my @columns = qw(qw(gi version cds); sub flush_info { # print out all information: print join '*', @info{@columns}; # and forget the collected information %info = (); }; while (<>) { if (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 } elsif (m!^VERSION.*\w:(\d+)! ) { $info{ version } = $1; } else { warn "Ignoring unknown line [$_]\n"; }; }; # Output any leftover information: flush_info();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Read, match string and print
by sophix (Sexton) on Feb 08, 2010 at 10:23 UTC | |
by Corion (Patriarch) on Feb 08, 2010 at 10:26 UTC | |
by sophix (Sexton) on Feb 08, 2010 at 10:38 UTC | |
by Corion (Patriarch) on Feb 08, 2010 at 10:44 UTC | |
by sophix (Sexton) on Feb 08, 2010 at 11:03 UTC | |
|