for (my $element = 0; $element<$total_element; $element++) #### for my $command (@run) { ... #### if (system( $run_cmd ) != 0) { print "Running command '$run_cmd' failed: $!/$?\n"; $err = 1; };