in reply to Re^2: Question regarding handling exceptions in subroutine
in thread Question regarding handling exceptions in subroutine
The obvious answer is to remove the croak (or perhaps change it to a carp/warn).
You can run a command in backticks to trap both the output and the status code it returns. So you should be able to do something like:
my $response=`useradd fred ....`; #check the status code (0 = success) if ($? >>8) { # we could not add the user }
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)
In Section
Seekers of Perl Wisdom