Next | Tricks of the Wizards | 130 |
sub delete_files { my ($dir) = @_; opendir my $dh, $dir or return; my $deleted = "0e0"; for (readdir $dh) { ++$deleted if unlink } return $deleted; }
unless (delete_files(...)) { die... }
$num_deleted = delete_files(...);
Function only returns false on an error
Even when it returns 0, it returns true
"0e0" is zero, but true
Also "0 but true" return from ioctl
DBI uses a similar trick
Next | Copyright © 2003 M. J. Dominus |