Does the script really die because of that? I ran the following in one terminal:
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' } ];
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

In reply to Re: remove_tree dies even when trapped with eval by choroba
in thread remove_tree dies even when trapped with eval by Alphaphi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.