in reply to Large File Parsing

I have to parse a 9GB textfile, I only want to keep lines containing certain strings (UniProt IDs, like P40303 or Q99436).

I would think that the first thing is to decide whether you even need to write any kind of program or not (Perl or otherwise)! I figure you are on a Unix type machine. There is a standard program that does what you want called "grep".

Type "man grep", "man egrep" at the command line to get some hints. "grep P40303 *.datafile" will output all lines containing P40303 in all files ending in ".datafile".

But if you must, here is some Perl code...

#!/usr/bin/perl -w use strict; my @items = qw (P40303 Q99436 X1234 W9765543); my $regex = join ("|",@items); print $regex; # to see what this does # put something like this in your "grep" # P40303|Q99436|X1234|W976554 while (<>) { print if m/$regex/; } __END__ Perl 5.10 is pretty smart. I think that the /o option is not necessary here. I don't think more complex syntax's are either.