File::Locate::Harder

File::Locate::Harder is a Perl module for when you're determined to use a locate db.
Download

File::Locate::Harder Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Joseph Brenner
  • Publisher web site:
  • http://search.cpan.org/~doom/

File::Locate::Harder Tags


File::Locate::Harder Description

File::Locate::Harder is a Perl module for when you're determined to use a locate db. SYNOPSIS use File::Locate::Harder; my $flh = File::Locate::Harder->new(); my $results_aref = $flh->locate( $search_term ); # using a defined db location, plus some locate options my $flh = File::Locate::Harder->new( db => $db_file ); my $results_aref = $flh->locate( $search_pattern, { case_insensitive => 1, regexp => 1, } ); # creating your own locate db, (in this example for doing tests) use Test::More; SKIP: { my $flh = File::Locate::Harder->new( db => undef ); $flh->create_database( $path_to_tree_to_index, $db_file ); if( $flh->check_locate ) { my $reason = "Can't get File::Locate::Harder to work"; skip "Can't run 'locate'", $test_count; } my $results_aref = $flh->locate( $search_term ); is_deeply( $results_aref, $expected_aref, "Found expected files"); } # introspection (is it reading db directly, or shelling out to locate?) my $report = $flh->how_works; print "This is how File::Locate::Harder is doing locates: $reportn";File::Locate::Harder provides a generalized "locate" method to access the file system indexes used by the "locate" command-line utility. It is intended to be a relatively portable way for perl code to quickly ascertain what files are present on the current system.This code is essentially a wrapper around multiple different techniques of accessing a locate database: it makes an effort to use the fastest method it can find that works.The "locate" command is a well-established utility to find files quickly by using a special index database (typically updated via a cron-job). This module is an attempt at providing a perl front-end to "locate" which should be portable across most unix-like systems.Behind the scenes, File::Locate::Harder silently tries many ways of doing the requested "locate" operation. If it can't establish contact with the file system's locate database, it will error out, otherwise you can be reasonably sure that a "locate" will return a valid result (including an empty set if the search matches nothing).If possible, File::Locate::Harder will use the perl/XS module File::Locate to access the locate db directly, otherwise, it will attempt to shell out to a command line version of "locate".If not told explicitly what locate db file to use, this module will try to find the file system's standard locate db using a number of reasonable guesses. If those all fail -- and it's possible for it to fail simply because file permissions make the db file effectively invisible -- as a last ditch effort, it will try shelling out to the command line "locate" without specifying a db for it (because it usually knows where to look).Efficiency may be improved in some circumstances if you help File::Locate::Harder find the locate database, either by explicitly saying where it is (using the "db" attribute), or by setting the LOCATE_PATH environment variable. Also see the "introspection_results" method. Requirements: · Perl


File::Locate::Harder Related Software