foreach my $command (@step) { next unless defined $command; # skip unused numbers my $ret= system ($command); ... }