in reply to look through directory for tar files only

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.

Replies are listed 'Best First'.
Re^2: look through directory for tar files only
by Anonymous Monk on Aug 04, 2015 at 21:52 UTC
    *cough*
    use File::Find::Rule qw/ find rule /; my @files = find( name => '*.tar', in => $dir );