sub getfiles { my ($dirName, @patterns) = @_; opendir(my $dir, $dirName) or die "Can't open '$dirName': $!"; my @return; for my $file (readdir($dir)) { for my $pattern (@ARGV) { if ($file =~ /$pattern/) { push @return, $file; # This avoids having the file in the result twice last; } } } return @return; } #### my @uploads = getfiles($logSite, @ARGV);