summaryrefslogtreecommitdiff
path: root/cpan/Compress-Raw-Zlib/examples/filtinf
diff options
context:
space:
mode:
Diffstat (limited to 'cpan/Compress-Raw-Zlib/examples/filtinf')
-rwxr-xr-xcpan/Compress-Raw-Zlib/examples/filtinf30
1 files changed, 30 insertions, 0 deletions
diff --git a/cpan/Compress-Raw-Zlib/examples/filtinf b/cpan/Compress-Raw-Zlib/examples/filtinf
new file mode 100755
index 0000000000..1a99e885b0
--- /dev/null
+++ b/cpan/Compress-Raw-Zlib/examples/filtinf
@@ -0,0 +1,30 @@
+#!/usr/local/bin/perl
+
+use Compress::Raw::Zlib ;
+
+use strict ;
+use warnings ;
+
+binmode STDIN;
+binmode STDOUT;
+
+my $x = new Compress::Raw::Zlib::Inflate
+ or die "Cannot create a inflation stream\n" ;
+
+my $input = '' ;
+my $output = '' ;
+my $status ;
+
+while (read(STDIN, $input, 4096))
+{
+ $status = $x->inflate($input, $output) ;
+
+ print $output
+ if $status == Z_OK or $status == Z_STREAM_END ;
+
+ last if $status != Z_OK ;
+}
+
+die "inflation failed\n"
+ unless $status == Z_STREAM_END ;
+