Explore BrainMass
Share

Explore BrainMass

    Perl find: locating single file or multiple files

    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 October 10, 2019, 12:23 am ad1c9bdddf
    https://brainmass.com/computer-science/perl/perl-find-locating-single-file-multiple-files-290133

    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.

    ----------------------------------------------------------------
    #!/usr/bin/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.

    $2.19