use File::Find; my $dir = "/home/lprjob1/filest" find( sub { push @files, $File::Find::name if -f && /.+gz/ }, $dir );