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

Re: Searching local files

by holli (Abbot)
on Jan 13, 2006 at 17:15 UTC ( #523032=note: print w/replies, xml ) Need Help??


in reply to Searching local files

There is, how surprising ;-), something readymade on CPAN (MyConText) that does exactly what the above posts suggest:
MyConText is a pure man's solution for indexing contents of documents. It uses the MySQL database to store the information about words and documents and provides Perl interface for indexing new documents, making changes and searching for matches. For MyConText, a document is nearly anything -- Perl scalar, file, Web document, database field.
It's so simple as:
use MyConText; use DBI; # connect to database (regular DBI) my $dbh = DBI->connect('dbi:mysql:database', 'user', 'passwd'); # create a new index my $ctx = MyConText->create($dbh, 'indexname', 'frontend' => 'file', ' +backend' => 'phrase'); # or open existing one # my $ctx = MyConText->open($dbh, 'indexname'); # index documents $ctx->index_document('/path/to/file'); # search for matches, finds documents that contain "anybody", "somebod +y", "nobody", etc. my @documents = $ctx->contains('%body');
Alternatives:


holli, /regexed monk/

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2023-10-01 06:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?