yunglean808 has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks! I need assistance with creating a function that will look recursively in an output directory for TAR files, and then returns them in a list as a path to another directory. Any insight would be very helpful. Thank you!
  • Comment on look through directory for tar files only

Replies are listed 'Best First'.
Re: look through directory for tar files only
by 1nickt (Canon) on Aug 04, 2015 at 16:57 UTC

    It's not clear what you mean by "and then returns them in a list as a path to another directory." if you need to copy or move the files, please post a follow-up question. Here's a suggestion for finding the files:

    See File::Find::Rule

    my $dir = '/some/path'; my @files = File::Find::Rule->file() ->name( '*.tar' ) ->in( $dir );
    Edit: simplified example
    The way forward always starts with a minimal test.
      *cough*
      use File::Find::Rule qw/ find rule /; my @files = find( name => '*.tar', in => $dir );
Re: look through directory for tar files only
by fishmonger (Chaplain) on Aug 04, 2015 at 16:56 UTC