Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Deleting a File

by Moron (Curate)
on Jun 20, 2007 at 13:38 UTC ( #622242=note: print w/replies, xml ) Need Help??

in reply to Deleting a File

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 } #... 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!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://622242]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2018-03-21 13:27 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.