Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    File::Locate::Harder 0.05

    Download button

    No screenshots available
    Downloads: 445  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Joseph Brenner | More programs
    Perl Artistic License / FREE
    October 28th, 2007, 07:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    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.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    locate database | Perl module | locate | database | Perl

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM