I'm looking for a combination of techniques to create a compressed file. Later I want to decompress that file on the fly and pass through pipe to the curl command.
The problem is the code I'm using produces a file that holds compressed data stream (as opposed to a file):
my $fh = IO::Zlib->new("file.gz", "wb9");
if (defined $fh) {
print $fh "some big data here!\n";
$fh->close;
}
Because of that I can't simply uncompress it using zcat:
zcat file.gz
zcat: can't stat: file.gz (file.gz.Z): No such file or directory
and the whole reason to do this is I was hoping to redirect zcat output as STDIN for curl command later:
zcat file.gz | curl -X PUT -d @- http://localhost:5822/
The above works if I create text file and gzip it. I was looking for an elegant way to do it from Perl, where I don't need to create temp file, zip it, delete temp file first.
This could be probably achieved in two ways:
1) find a way to create compressed file containing file data (as opposed to data stream)
2) find a Linux/Unix/OSX command that deals with files with stream compressed data (like zcat apparently can't)
Would be grateful for help re. both ways