Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Is there a definitive module for efficiently searching a collection of text files?

by Anonymous Monk
on Mar 18, 2025 at 10:32 UTC ( [id://11164314]=note: print w/replies, xml ) Need Help??


in reply to Is there a definitive module for efficiently searching a collection of text files?

Do you have any requirement that grep doesn't satisfy?
  • Comment on Re: Is there a definitive module for efficiently searching a collection of text files?

Replies are listed 'Best First'.
Re^2: Is there a definitive module for efficiently searching a collection of text files?
by nysus (Parson) on Mar 18, 2025 at 12:59 UTC

    Two things: getting something off the shelf that just works and avoiding agonizing over the minutiae of grep commands. And taking care of details like file locking, fast searching and making multiple changes to files in memory to make things more efficient.

    I've started to patch a solution together myself with Path::Iterator::Rule for selecting files of interest and then creating a custom file object that will handle in memory search and replaces and file locking. It's probably overkill for what I need but I'd rather make sure I try to do it right. I won't be able to beat grep when it comes to raw searching speed, but I'm not too concerned about that. I'm only dealing with a few hundred files at most.

    $PM = "Perl Monk's";
    $MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
    $nysus = $PM . ' ' . $MC;
    Click here if you love Perl Monks

      You said: "I'm only dealing with a few hundred files at most."

      I would forget about optimizing. Do what is the easiest thing for you to implement. I think you are looking at well less than a minute, maybe even just some ten's of seconds. Also, since these are only relatively small text files (software source), the file will probably be in disk cache if you need to read it again.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2025-05-21 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.