Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to optimize a regex on a large file read line by line ?

by graff (Chancellor)
on Apr 16, 2016 at 16:29 UTC ( [id://1160654]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    print "Num. Line : $. - Occ : $counter2\n";
    
  2. or download this
    unzip -p 10-million-combos.txt.zip | perlscript
    
  3. or download this
    $ unzip -p 10-million-combos.txt.zip | time grep -c 123456$
    0
    ...
    $ unzip -p 10-million-combos.txt.zip | time perl -ne 'BEGIN{$n=0} $n++
    + if /123456$/; END{print "$. lines, $n matches\n"}'
    9835513 lines, 0 matches
            1.93 real         1.90 user         0.02 sys
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1160654]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-03-29 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found