Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Handling weird return values with or die

by bikeNomad (Priest)
on Jul 05, 2001 at 20:00 UTC ( [id://94142]=note: print w/replies, xml ) Need Help??


in reply to Handling weird return values with or die

Or, you could just use Archive::Zip and do it all in Perl:

use Archive::Zip; use Archive::Zip::Tree; use File::Temp; use File::Basename; my $zip = Archive::Zip->new(); $zip->read($target) and die "can't read $target\n" if -f $target; $zip->addTree($project_root, $project_root); if (-f $target) # existing file? { my ($tmpfh, $tmpname) = File::Temp::tempfile( DIR => dirname($target +)); $zip->writeToFileHandle( $tmpfh ) and die "Can't write to $tmpname\n +"; $tmpfh->close(); unlink($target) or die "can't remove $target: $!\n"; rename($tmpname, $target) or die "can't rename $target: $!\n"; } else { $zip->writeToFileNamed($target) and die "can't write to $target\n" +; }

Hmm... maybe I should add the write back to same file ability to Archive::Zip.

Replies are listed 'Best First'.
Re: Re: Handling weird return values with or die
by mvaline (Friar) on Jul 05, 2001 at 20:30 UTC
    Thanks! I only carry around the zip program for my scripts to use; now I don't have to.

    /me makes mental note to always check CPAN before he does anything. :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-29 02:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found