Hi Thank you for the feedback. But I don't see any difference between my script and CPAN's documentation. Actually, I do follow it to write my script.
> > > On Fri, Sep 26, 2008 at 12:17 AM, Yue Chen <[EMAIL PROTECTED]> wrote: >> >> Hi >> >> I want to use rmtree to delete a dir and use variables to catch the >> error message. However, when i am about to delete a dir that does not >> belong to me, it still print the error message to stderr. Does anyone >> have clue? >> >> my script: test.pl >> >> use File::Path; >> File::Path::rmtree( '/root', {error => \$err, safe => 1, result => >> \$list, keep_root => 1} ); >> for my $diag (@$err) { >> my ($file, $message) = each %$diag; >> print "problem unlinking $file: $message\n"; >> } >> print "unlinked $_\n" for @$list; >> >> $ test.pl >> Can't make directory /root read+writeable: Operation not permitted at >> a.pl line 2 >> Can't read /root: Permission denied at a.pl line 2 >> rmdir /root >> Can't remove directory /root: Permission denied at a.pl line 2 >> and can't restore permissions to 0750 >> at a.pl line 2 >> >> -- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> http://learn.perl.org/ >> >> > > from File::Path documentation: > > rmtree( > 'foo/bar/baz', '/zug/zwang', > { verbose => 1, error => \my $err_list } > ); > > error > If present, will be interpreted as a reference to a list, and > will > be used to store any errors that are encountered. See the ERROR > HANDLING section for more information. > > If this parameter is not used, certain error conditions may raise > a > fatal error that will cause the program will halt, unless trapped > in an "eval" block. > > ERROR HANDLING > If "mkpath" or "rmtree" encounter an error, a diagnostic message will > be printed to "STDERR" via "carp" (for non-fatal errors), or via > "croak" (for fatal errors). > > If this behaviour is not desirable, the "error" attribute may be used > to hold a reference to a variable, which will be used to store the > diagnostics. The result is a reference to a list of hash references. > For each hash reference, the key is the name of the file, and the > value > is the error message (usually the contents of $!). An example usage > looks like: > > rmpath( 'foo/bar', 'bar/rat', {error => \my $err} ); > for my $diag (@$err) { > my ($file, $message) = each %$diag; > print "problem unlinking $file: $message\n"; > } > > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/