#!/usr/bin/perl $USAGE = ' SYNOPSIS: convert *.tgz to *.zip files, on NT and Unix. AUTHOR: http://www.cs.albany.edu/~mosh USAGE: c:/> ls -l *.tgz c:/> perl tar2zip PASS *.tgz c:/> ls -l *.zip; c:/> unzip -p PASS -vt *.zip c:/> rm *.tgz '; $pass = shift || die $USAGE; if( -e "$pass" or $pass =~ /\.tgz/i ){ die "pass=$pass, forgot pass?\n"; } sub doit { my $cmd = shift; print "doit $cmd \n"; my $status = system( $cmd ) ; if( $status % 255 ){ die "Failed: doit $cmd\n"; } } while($base = shift @ARGV){ unless( $base =~ s/\.tgz//i ){ die "$base !~ m/.tgz/\n"; } #====Sanity check unless(-r "$base.tgz"){ die "cannot read $base.tgz\n"; } if(-e $base){ die "./$base exists\n" }; if(-e "$base.zip"){ die "$base.zip exists.\n"; } warn "---------------- $base -------------\n"; #====Untar into dir mkdir $base, 0755; chdir $base; doit "gzip -dc ../$base.tgz | tar -xvf -"; chdir ".."; #====Make the archive doit "zip -P $pass -rTe $base $base"; #====Test the archive unless(-r "$base.zip"){ die "Cannot read $base.zip \n"; } doit "unzip -P $pass -qq -vt $base"; #====Delete the dir doit "rm -rf $base"; if(-e $base){ die "Cannot purge ./$base\n"; } }