http://www.perlmonks.org?node_id=421265


in reply to Genbank file parsing

You might find it easier if your consider the file as a long string, one that happens to contain embedded newline characters.

my $data = do {local $/; <DATA>}; my @items = map { { 'name' => $1, 'niceinfo' => $2 } } ($data =~ /^FEATURES(.+?)^ORIGIN(.+?)^\/\//msg);

 

Replies are listed 'Best First'.
Re^2: Genbank file parsing
by blazar (Canon) on Jan 11, 2005 at 14:03 UTC
    You might find it easier if your consider the file as a long string, one that happens to contain embedded newline characters.
    IMHO this qualifies as a particularly bad answer since he specifically pointed out that his file is large and it is always recommended not to slurp large files all at once if possible. Now I don't see anything here that suggests this to be necessary...

      It depends just how large the file is, how much memory is available, and other various trade-offs. But you are probably right in general, although I would quibble about "particularly bad" :-/