in reply to remove_tree dies even when trapped with eval
my $list = join ',', 'a' .. 'z'; mkdir '1'; open my $FH, '>', $_ for glob '1/' . ("{$list}" x 3);
And while it was running, I ran the following in the same directory in the second terminal:
use File::Path qw{ remove_tree }; print remove_tree('1'); print "FINISHED\n";
I got the error message you mentioned, but "FINISHED" was printed, too, so the program didn't die. The documentation is somehow unclear on this:
If make_path or remove_tree encounter an error, a diagnostic message will be printed to STDERR via carp (for non-fatal errors), or via croak (for fatal errors).If you just want to avoid the message, you can use the documented error option:
use Data::Dumper; use File::Path qw{ remove_tree }; my $err; remove_tree('1', { error => \$err }); print Dumper($err);
Which returns:
$VAR1 = [ { '1' => 'cannot remove directory: Directory not empty' } ];
|
|---|