In addition:
if ($run_cmd =~ /check.pl/)is an unnecessary use of the regular expression engine (which is a really complex beasty).
if ($run_cmd eq 'check.pl')
is much easier.
By the way, when submitting code please at least show how your variables are derived. Many have said that the C-style
for loop is unnecessary, but actually we do not know what
$total_element is. We can only guess it is the highest index number in
@run