in reply to Error trapping, and improving code
The system calls will return nonzero if they fail, so a construction like, (my $res = system @args) and unlink $to_delete; will work. The return value is kept in $res in case you want to do something more about it.
Update: Ok, here's a fancier version
UFILE: while (@files) { #... system @args and do { unlink $to_delete; print LOG "'system @args' failed: ", $?; next UFILE; }; system @other_args and print LOG "'system @other_args' failed: ", $?; #... }
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Error trapping, and improving code
by hiddenlinux (Acolyte) on Jul 05, 2003 at 16:32 UTC | |
|
Re: Re: Error trapping, and improving code
by hiddenlinux (Acolyte) on Jul 06, 2003 at 07:38 UTC |