use strict; BEGIN { open(STDERR, ">stderr.log") or die "Failed to open log file"; } my $slot_outfile = "results.csv"; open my $SLOT_OUTFILE, q{>}, $slot_outfile or die; my @REG_list = qw{Regulation_AZT Regulation_IOP Regulation_AERTC}; chdir(".."); chdir("ALL_WEEKS"); my $reg; my $week = "W36"; foreach $reg (@REG_list){ chdir("semaine_${week}/${reg}") or die "Can't go into the directory $reg!"; my @SLOTS = glob("slot_list*.out"); my @SLOTS_01 = grep /(\w+).(\d\d).(01).(\w+).out/, @SLOTS; my $slot_file = $SLOTS_01[0]; my $cmd = "perl ../../../WP4_utility_analysis/WP4_utility.pl $slot_file $SLOT_OUTFILE"; system($cmd); chdir("../.."); }