On Apr 23, 11:56 am, abuali...@gmail.com (galeb abu-ali) wrote:
> thank you for the advice Shawn, I'll try what you suggest!
> BTW, it's not homework, It's supporting metadata for my research and I'm
> trying to parse it in a format that will be easier to lookup later.
>
> thanks again
>
> galeb

Hi Galeb,

Might I offer a suggestion? Instead of parsing the lines into data
structures to be printed at the end of each file, just print out the
whole (matching) line and defer the parsing of certain fields until a
later time. It will greatly simplify your code and just acts as a
filter to print only the tab seperated data of interest.

#!/usr/bin/perl
use strict;
use warnings;

# perl parse_IMG_gene_info4.pl your_input_file_here01.txt
your_input_file_here02.txt (etc.)

while( <> ) {
    print if /COG_category/ || /COG\d+/;
    print "\n" if eof;
}

Just offering an idea.  :-)
Chris


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to