Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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


Comment on Re: Deleting a File
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://622242]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-09-19 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (147 votes), past polls