foreach ($firstbuild, @otherbuilds) { system (qq(C:/execu $_ file.c)); } #### open (OUT, ">cmd.txt") || die "$!\n"; foreach ($firstbuild, @otherbuilds) { print OUT "C:/execu $_ file.c\n"; } close OUT; system ("cmd.txt");