Re: Searching large files with a regex and a list
- From: "Brian McCauley" <nobull67@xxxxxxxxx>
- Date: 31 May 2006 10:42:11 -0700
Channing wrote:
I would like some suggestions (constructive) on some code I'm writing.
My Perl is rusty and that's reflected in the sample I'm posting. Here
is what I have to tackle. I have Gig files to parse for two different
RegEx's. Within those RegEx's there is a variable that is a list of
18,000+ numbers. I'm looking for some suggestions on what I can do to
speed things up, or at least make things better.
Thanks in advance for your time.
------- Code Begin ---------
#!/usr/bin/perl
my $match=0;
my $nonMatch=0;
open(DN_LIST, "<","big_list");
my @list = <DN_LIST>;
@list=sort(@list);
close(DN_LIST);
foreach (@list)
{
chomp;
s/ //g;
}
@list = join('|',@list);
Joining multiple RegEx into one like this is _less_ efficient than
simply looping over @list, which is why the answer given in the FAQ
(yes, your question is a FAQ) does not suggest doing so. (It does
suggest using qr// to precompile the RegEx though...
$_=qr/$_/; # Inside your loop
.
- Follow-Ups:
- Re: Searching large files with a regex and a list
- From: Channing
- Re: Searching large files with a regex and a list
- References:
- Searching large files with a regex and a list
- From: Channing
- Searching large files with a regex and a list
- Prev by Date: Re: better idiom for appending to list from file
- Next by Date: Re: Changing the inherited STDOUT
- Previous by thread: Re: Searching large files with a regex and a list
- Next by thread: Re: Searching large files with a regex and a list
- Index(es):
Relevant Pages
|