I’m used to `… or die “.. failed… $!”;.
I was surprised to find that in order to know if File::Path::remove_tree failed or not I must do something like this:
remove_tree( 'foo/bar', 'bar/rat', {error => \my $err} );
if (@$err) {
die "error..."
}
Am I missing something? Is this really the way to go?
A lot of unneeded code for me…
remove_treereturns the number of files successfully deleted, so it needs another method of reporting an error than a return value. Bear in mind that a number of files may have been deleted before an error is encountered, so you can’t rely on the returned value being 0 as indicating an error.Whether this is the way to go for reporting errors is a matter of taste. From the docs themselves: