Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm performing the following operation

IO::Compress::Gzip::gzip $originalPath => $gzippedPath

However, the original full path to the file is preserved in the gzip archive. Is there any way to prevent this other than changing to the directory containing the original file and doing this (Below)? TIA.

IO::Compress::Gzip::gzip $originalFile => $gzippedPath

Replies are listed 'Best First'.
Re: IO::Compress::gzip and Hierarchies
by kyle (Abbot) on Sep 24, 2007 at 19:21 UTC

    By my reading of the IO::Compress::Gzip documentation, you could do something like this:

    open my $fh, '<', $originalFile or die "Can't read '$originalFile': $!\n"; IO::Compress::Gzip::gzip $fh => $gzippedPath; close $fh or die "Close failed on '$originalFile: $!\n";

    Update: Upon further reading, it seems you can use optional parameters to override the name or write a gzip file without that data.

    # No name, no time (nameless and timeless?) IO::Compress::Gzip::gzip $originalFile => $gzippedPath, Minimal => 1; # A name of my choosing. IO::Compress::Gzip::gzip $originalFile => $gzippedPath, Name => 'Nyuck' x 3;