for (my $element = 0; $element<$total_element; $element++) { my ($run_cmd, $chdir_cmd) = split(';',$run[$element],2); ch_dir($chdir_cmd,$patch,'0'); if ($run_cmd =~ /check.pl/) { system($run_cmd) if ($? != 2) { print "Command Failed: While Executing $run_cmd$!\n"; $err = 1; } } else { system($run_cmd); if ($? != 0) { print "Command Failed: While Executing $run_cmd$!\n"; $err = 1; } } }