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!


In reply to Re: Deleting a File by Moron
in thread Deleting a File by phimtau123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.