Explore BrainMass

Explore BrainMass

    Perl find: locating single file or multiple files

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Please help with the following programming problem.

    I always use the following find command in Unix to locate one or several files:

    find / -name filename -type f 2>errormessage

    The Unix find command is very slow. It takes lot of time to get the required results. I was told Perl has one of the best find command.

    Please provide me the find command for Perl. How to use it? How the result will be displayed? Using the command I should be able to locate a single file or multiple files.

    © BrainMass Inc. brainmass.com March 4, 2021, 9:59 pm ad1c9bdddf

    Solution Preview

    An example implementation is given below. You can refer to the following link: http://search.cpan.org/~lbrocard/perl5.005_04/lib/File/Find.pm for more details on find facility of Perl.


    use File::Find;

    sub search_a_file {
    /^hello.txt$/ && print $File::Find::name . "n";

    sub search_many_files {
    /.txt$/ && print $File::Find::name . ...

    Solution Summary

    This solution helps with a problem regarding the programming language, Perl.