G'day shroh,
Firstly, do yourself (and all subsequent maintainers) a favour by removing all the extraneous whitespace your code is littered with and pick (and stick to) some consistent indentation scheme. perlstyle - Perl Style Guide may help you with this.
"I am running a command on each element of an array, ..."
I'm guessing this is @nodelist; although, I'm not entirely sure. You are running a command for every element of that array. Below, I've just referred to @command_array: I'll leave you to modify as appropriate.
"I am handling the errors in a subroutine."
I see "sub processError {...}" but you don't call it anywhere. I'll assume this is what you're referring to.
Near the top of your script, add:
my @command_array; my $command_error_count = 0;
Limit the scope of these with an anonymous block if necessary.
In "sub processError {...}", increment $command_error_count.
When processing is finished, you can then access (for your log entry):
— Ken
In reply to Re: Error Handling the Perl script
by kcott
in thread Error Handling the Perl script
by shroh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |