Searching large files with a regex and a list
- From: "Channing" <channing.clark@xxxxxxxxx>
- Date: 30 May 2006 20:00:49 -0700
Hello All -
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);
while (<>)
{
if ( /^123456\d{8}($list[0])/o or /^9876(91|92)\d{24}($list[0])/o )
{
$match++;
}
else
{
$nonMatch++;
}
}
print "Match Count:" . ${match} . "\n";
print "Non-Match Count:" . ${nonMatch} . "\n";
------- Code End ---------
.
- Follow-Ups:
- Re: Searching large files with a regex and a list
- From: Brian McCauley
- Re: Searching large files with a regex and a list
- From: attn.steven.kuo@xxxxxxxxx
- Re: Searching large files with a regex and a list
- From: John W. Krahn
- Re: Searching large files with a regex and a list
- From: Bob Walton
- Re: Searching large files with a regex and a list
- Prev by Date: Re: How to match characters in different locations within string
- Next by Date: Re: How to have a Perl script emulate a keystroke to another application
- Previous by thread: FAQ 3.27 Where can I learn about object-oriented Perl programming?
- Next by thread: Re: Searching large files with a regex and a list
- Index(es):
Relevant Pages
|