I'm having this very weird where i'm using rmtree("C:\myfolder"); and it's throwing some kind of exception but it is doing what it is supposed to.
I have this enclosed in
eval {
rmtree("C:\myfolder");
};
if($@) {
print $@;
}
If the folder exists I get an exception thrown eventhough the folder is succesfully deleted. The thrown exception is blank nothing at all. I even tried setting rmtree("C:\myfolder", {verbos开发者_Python百科e => 1}) in rmtree but same thing.
My current hack is to do
eval {
eval {
rmtree("C:\myfolder");
};
};
if($@) {
print $@;
}
How can you detect a blank exception??
From perldocs:
remove_tree( 'foo/bar', 'bar/rat', {error => \my $err} );
if (@$err) {
for my $diag (@$err) {
my ($file, $message) = %$diag;
if ($file eq '') {
print "general error: $message\n";
}
else {
print "problem unlinking $file: $message\n";
}
}
}
else {
print "No error encountered\n";
}
In Windows, I know that relative paths work with /
. I think absolute paths work with /
too!
remove_tree("C:/myfolder"); #this should work
try escaping the backslash ie.
"C:\\myfolder"
精彩评论