One thing you could do is precompile the regex and save it in a variable
ala

my $regex = qr/.*ST\S+\s*\S*B15--.*[^02468]]/o;
my @match_sp = $all_lines =~ /$regex/mg;

Note the 'o' option on the qr//, which tells perl to compile the regex
only once.

I'm not sure if it applies in this case or not, but it's something to
check.



-----Original Message-----
From: Alan Campbell [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 19, 2006 3:13 PM
To: beginners@perl.org
Subject: reg exp speed?

hello folks,
   
  I'm slurping in a large file and seeing a nice speedup versus line by
line processing...but I'm losing it in my (likely poorly constructed!)
reg-expression match
   
<snip explanation>

   my @match_sp = $all_lines =~ /.*ST\S+\s*\S*B15--.*[^02468]]/mg;
   
<snip>


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to