in reply to parsing multiple lines
By changing the process subroutine you can re-use this code to perform different kinds of analyses on the file.my $r = {}; # hash to hold the parsed record while (<IN>) { if (/^(\d+).../) { # found beginning of new record if ($r->{id}) { process($r); } $r = {}; # begin new record $r->{id} = $1; # populate parsed info from this line } elsif (/KEGG.../) { $r->{kegg} = ...; } elsif ... } } if ($r->{id}) { process($r) }; sub process { my $r = shift; ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parsing multiple lines
by GrandFather (Saint) on May 21, 2008 at 21:19 UTC | |
|
Re^2: parsing multiple lines
by sm2004 (Acolyte) on May 22, 2008 at 00:53 UTC |