RobertCraven has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
this question has been raised before. Unfortunately I was not able to transfer the answers to my problem.
I have to parse a 9GB textfile, I only want to keep lines containing certain strings (UniProt IDs, like P40303 or Q99436).The runtime is endless, could anyone recommend me a better way?#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @items; foreach my $key (keys %hash){ push(@items,$key); } my $rxMatchItems; { local $" = q{|}; $rxMatchItems = qr{(?:@items)}; } open(FH,'<','gene_association.goa_uniprot') or die "Can not open/acces +s 'gene_association.goa_uniprot'\n$!"; while(<FH>){ next unless m{$rxMatchItems}; print $_; } close(FH);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Large File Parsing
by jwkrahn (Abbot) on Jan 03, 2010 at 04:25 UTC | |
by Anonymous Monk on Jan 03, 2010 at 05:36 UTC | |
by johngg (Canon) on Jan 03, 2010 at 11:19 UTC | |
|
Re: Large File Parsing
by educated_foo (Vicar) on Jan 03, 2010 at 06:44 UTC | |
by afoken (Chancellor) on Jan 03, 2010 at 09:25 UTC | |
by Jenda (Abbot) on Jan 03, 2010 at 11:32 UTC | |
by RobertCraven (Sexton) on Jan 03, 2010 at 23:24 UTC | |
by educated_foo (Vicar) on Jan 03, 2010 at 18:21 UTC | |
by Jenda (Abbot) on Jan 03, 2010 at 21:15 UTC | |
by RobertCraven (Sexton) on Jan 03, 2010 at 23:20 UTC | |
|
Re: Large File Parsing
by Marshall (Canon) on Jan 03, 2010 at 23:20 UTC | |
|
Re: Large File Parsing
by Anonymous Monk on Jan 03, 2010 at 04:15 UTC | |
by RobertCraven (Sexton) on Jan 03, 2010 at 23:14 UTC |