Re: regex optimization

2010-01-09 Thread Erez Schatz
2010/1/9 C.DeRykus : > On Jan 5, 12:13 am, moonb...@gmail.com (Erez Schatz) wrote: >> 2010/1/5 Jeff Peng : >> ... >> >> This is something that Perl  (post version 5.6) does inherently, which >> is compiling a regex only once as long as the pattern isn't modified. > >> Prior to 5.6 you'd need to use

Re: regex optimization

2010-01-09 Thread C.DeRykus
On Jan 5, 12:13 am, moonb...@gmail.com (Erez Schatz) wrote: > 2010/1/5 Jeff Peng : > ... > > This is something that Perl  (post version 5.6) does inherently, which > is compiling a regex only once as long as the pattern isn't modified. > Prior to 5.6 you'd need to use the /o modifier ( > m/href="h

Re: regex optimization

2010-01-06 Thread C.DeRykus
On Jan 5, 12:13 am, moonb...@gmail.com (Erez Schatz) wrote: > 2010/1/5 Jeff Peng : > > ... > This is something that Perl  (post version 5.6) does inherently, which > is compiling a regex only once as long as the pattern isn't modified. > Prior to 5.6 you'd need to use the /o modifier ( > m/href="ht

Re: regex optimization

2010-01-06 Thread Brad Baxter
Dr.Ruud wrote: Jeff Peng wrote: Can the code (specially the regex) below be optimized to run faster? #!/usr/bin/perl for ($i=0; $i<1000; $i+=1) { open HD,"index.html" or die $!; while() { print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/; } close HD; } Let me first "normal

Re: regex optimization

2010-01-06 Thread Dr.Ruud
Jeff Peng wrote: Can the code (specially the regex) below be optimized to run faster? #!/usr/bin/perl for ($i=0; $i<1000; $i+=1) { open HD,"index.html" or die $!; while() { print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/; } close HD; } Let me first "normalize" the code.

Re: regex optimization

2010-01-05 Thread John W. Krahn
Jeff Peng wrote: Hello, Hello, Can the code (specially the regex) below be optimized to run faster? #!/usr/bin/perl for ($i=0; $i<1000; $i+=1) { ++$i is usually faster than $i+=1. But you are not using the $i variable so you don't really need it (your Ruby programs don't have it.) for

Re: regex optimization

2010-01-05 Thread Erez Schatz
2010/1/5 Jeff Peng : > Hello, > > Can the code (specially the regex) below be optimized to run faster? > > #!/usr/bin/perl > for ($i=0; $i<1000; $i+=1) { > >  open HD,"index.html" or die $!; >  while() { >   print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/; >  } >  close HD; > } theore

not a beginner question (was Re: regex optimization)

2010-01-04 Thread Uri Guttman
> "JP" == Jeff Peng writes: JP> Hello, JP> Can the code (specially the regex) below be optimized to run faster? we seem to be getting a bunch of these questions which i would say are not beginner's questions. please post this to usenet or perlmonks which do regex optimizations all the ti