use strict; use warnings; use File::Slurp qw(read_dir); my @dirs = grep { -d } read_dir('./'); for (@dirs) { chdir $_; system '/somepath/foo.exe'; }