use File::Spec::Functions 'catdir'; sub do_em { my $path_to_companies = shift; opendir $dh, $path_to_companies or die "Can't opendir $path_to_companies: $!\n"; while ( my $company = readdir( $dh ) ) { next if $company ~= /^\./; my $dir = catdir( $path_to_companies, $company ); next unless -d $dir; my $module = 'Crunch::' . $company; eval "require $module; $module\::do_it( '$dir' ); 1" or die; } }