if ($file =~ /alphat_(.*)\.zip) { my $key = $1; # whatever was between alphat_ and the .zip bits. if (-f "numerict_${key}.zip && -f "updatet_${key}.zip") { print "Caught 'em all!\n"; } }