>>>>> "JG" == Jim Green <student.northwest...@gmail.com> writes:

  JG> Is there a preferred way to append a text file to the end of gzipped
  JG> file? the api of File::Slurp append_file is nice, but doesn't work
  JG> with gzip file...

wow, that is an odd request. there is no direct way i think with
append_file. maybe with edit_file and calling a gzip module to unzip,
append the text and gzip the result into $_ could do it. you could also
do soemthing like this (rough code, untested and i think the -c option
is zip/unzip to stdio - fix as needed)


open my $in, "gunzip -c $file|" or die ;
open my $out, "| gzip -c $file|" or die ;
write_file $out, read_file( $in ) . $append_text ) ;

the same with edit_file could be like this (again very rough code as i
don't know the gzip module api so fix this)

use Compress:gzip ; # or whatever the real module is
use File::Slurp qw( edit_file ) ;

edit_file { my $text = uncompress $_ ; $_ = compress "$_$append_text" } $file ;

hope that helps.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to