# Fetch all .zip files in the incoming directory my @zipfiles = glob "$srcDir/*.zip"; # Scan through the files to find out which XXX bits may exist my %XXXlist; for my $file (@zipfiles) { if ($file =~ /(alphat|numerict|updatet).(.*).zip/) { # OK one of our desired prefixes match, second capture group is a valid XXX value $XXXlist{$2}++; } } # Now we can go on and see what we can process for my $XXX (keys %XXXlist) { if (-E "$srcDir/alphat.$XXX.zip" and -E "$srcDir/numerict.$XXX.zip" and -E "$srcDir/updatet.$XXX.zip") { # all files are found, so go do some work } else { # Not all files are present yet. } }