On Wed, Dec 12, 2001 at 02:54:31PM +0000, Nicholas Clark wrote:
> I think I'm about to screw up again. I feel I need a function for a test
> script that deletes all versions of test files, and every time I try to write
> one that is portable to VMS and warns on unexpected failures I get something
> wrong (usually looping forever on Cygwin where nasty extension assumptions
> bite me).

Does this involve -e and trying to delete a .exe file?


> Please could someone else with access to VMS and Cygwin and other non-unix
> platforms (that I don't have access to)  write a single, good, reliable,
> recycle-your-temporary-files-back-to-free-disk-blocks function for test.pl?
> [I think I'm thinking of something that takes a list of files and vaporises
> any that actually exist, but warns if a file that is there fails to vaporise]
> Beg beg, grovel, grovel. I'll buy you a coffee.

Assuming "1 while unlink $foo" isn't doing it for you for some reason.
How about:

    sub stomp {
        my $file = shift;
        my $rslt = unlink $file;
        if( $^O eq 'VMS' ) {
            local $!;
            1 while unlink $file;
        }
        return $rslt;
    }

So you've got the return value and $! preserved and you can do with
them as you wish.  Works on Linux and VMS fine and shouldn't give you
any trouble on Cygwin.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Here's some scholarly-ass opinions...

Reply via email to