Show
Ignore:
Timestamp:
11/19/08 15:56:35 (5 years ago)
Author:
kazuho
Message:

use MIME::Base64 instead of uu(en|de)code, change gzcat to gunzip

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/misc/tgz2cgi/tgz2cgi.pl

    r24262 r24265  
    44use warnings; 
    55use Getopt::Long; 
     6use MIME::Base64; 
    67 
    78my $title = 'CGI Self Extractor'; 
     
    3637#! /usr/bin/perl 
    3738 
     39use MIME::Base64; 
     40 
    3841sub abort { 
    3942    print $_[0]; 
     
    6366EOT 
    6467} 
    65 open FH, '| uudecode -o /dev/stdout | gzcat | tar xvf -' 
     68open FH, '| gunzip | tar xvf -' 
    6669    or abort("failed to start extraction:$!"); 
    67 print FH << '__end_of_archive__'; 
     70print FH decode_base64(<< '__end_of_archive__'); 
    6871__EOT__ 
    6972; 
    7073 
    71 open my $fh, '-|', 'uuencode - < /dev/stdin' 
    72     or die "failed to call uuencode:$!"; 
    73 while (my $l = <$fh>) { 
    74     print $l; 
     74binmode STDIN; 
     75my $tgz = ''; 
     76while (read(STDIN, my $buf, 1048576) > 0) { 
     77    $tgz .= $buf; 
    7578} 
     79print encode_base64($tgz); 
     80 
    7681print << '__EOT__'; 
    7782__end_of_archive__