To quote a Dutch saying, "meten is weten" (measuring is knowing). Or to put it another way, not only do you need to take the general step of measuring return values from builtin and other calls but you often need to take the further step of taking further measurements where that wouldn't be enough! On unix and linux, one has the luxury of the shrink-wrapped machine (or new linux installation) having pretty the same user environment it's destined for in production and reasonable assumptions can be made about permissions and suchlike. With Windows in a corporate environment, not that I work with it, I'd probably overtest such things, but anyway, here is the kind of "paranoid lots of measuring" coding sytle I'd adopt. It's incomplete because a lot of work just the first time round developing the "Paradoze" package I'd put together, but this should give some idea what I'd be up to:
use Paradoze;
my $dh = Opendir( 'drwx', $dir ); # use standard "paranoid" routines
while ( my $file = Readdir( 'rwx', $dh ) ) {
my $path = "$dir/$file"; # do this anyway rather than expecting sa
+me directory!!
FileTests( 'rwx', "$dir/$file" );
# process the file
}
#... Paradoze.pm
package Paradoze; # paranoid utilities for windows corporate environme
+nts
sub Opendir {
my ( $mask, $path ) = @_;
FileTests( $mask, $path );
opendir my $dh, $path or die "$! for path $path\n";
$dh;
}
sub Readdir {
my ( $mask, $dh ) = @_;
# ...
}
sub FileTests {
my ( $mask, $path ) = @_;
for my $test ( split( '', $mask ) {
eval "( -$test $path )" or FTFatal( $test, $path )";
#...
}
__________________________________________________________________________________
^M Free your mind!