Professional Web Applications Themes

IO::Filter::gzip question - PERL Beginners

Can someone tell me how to extract the uncompressed data from the returned value using the script below? I try and print the $fio variable, but I get some hash reference. Do I need to iterate through this hash and then print the values or am I just going about this all wrong? I am trying to just open the gzip file and read the contents. I am using this module because I am limed to a box running 5.6. Thanks in advance. script: =========== #!/usr/bin/perl use IO::Filter::gzip; $io = "denver.gz"; $fio = new IO::Filter::gzip ($io, "r"); print "$fio\n"; ouput: ...

  1. #1

    Default IO::Filter::gzip question

    Can someone tell me how to extract the uncompressed data from the returned value using the script below? I try and print the $fio variable, but I get some hash reference. Do I need to iterate through this hash and then print the values or am I just going about this all wrong? I am trying to just open the gzip file and read the contents. I am using this module because I am limed to a box running 5.6.

    Thanks in advance.

    script:
    ===========
    #!/usr/bin/perl
    use IO::Filter::gzip;
    $io = "denver.gz";
    $fio = new IO::Filter::gzip ($io, "r");
    print "$fio\n";

    ouput:
    ===========
    $./test.pl
    IO::Filter::gzip=HASH(0x8132004)


    --
    Jose Malacara
    [email]josemthrifty.net[/email]
    Jose Malacara Guest

  2. #2

    Default Re: IO::Filter::gzip question

    > Can someone tell me how to extract the uncompressed data from the
    returned value using the script below? I try and print the $fio
    variable, but I get some hash reference. Do I need to iterate through
    this hash and then print the values or am I just going about this all
    wrong? I am trying to just open the gzip file and read the contents. I
    am using this module because I am limed to a box running 5.6.
    >
    > Thanks in advance.
    >
    > script:
    > ===========
    > #!/usr/bin/perl
    > use IO::Filter::gzip;
    > $io = "denver.gz";
    > $fio = new IO::Filter::gzip ($io, "r");
    > print "$fio\n";
    >
    > ouput:
    > ===========
    > $./test.pl
    > IO::Filter::gzip=HASH(0x8132004)
    >
    First I will suggest you should use Compress::Zlib which should be
    available for just about any Perl version, and certainly works in 5.6.x.

    Having said that, it isn't really what you asked, so I would suggest
    taking a look at the base IO::Filter module's doentation, as it
    appears that IO::Filter::gzip inherits most of its "good stuff" from
    that, it can be found here:

    [url]http://search.cpan.org/~rwmj/IO-Filter-0.01/lib/IO/Filter.pm[/url]

    Also be warned that you have to have 'gzip' installed and in your path
    for it to work (which if you do presumably the zlibs are available, and
    you should go back to using Compress::Zlib)...

    Assuming we are still here, then what you are getting in your $fio is a
    blessed reference, aka an IO::Filter object, that you can then apply a
    method tu, tu get your data... However what you pass to the constructor
    also needs to be an opened file handle rather than the path to a file to
    open, and you need to call the proper directional constructor, aka you
    want to unzip rather than zip, so you end up with something like:

    -- UNTESTED --

    #!/usr/bin/perl
    use strict; # always
    use warnings; # usually

    use IO::Filter::gunzip;

    my $zipped_file = "denver.gz";
    my $READHANDLE;
    open($READHANDLE, $zipped_file) or die "Can't open handle on zipped
    file: $!"; # you may want to set the binmode on this guy

    my $fio = new IO::Filter::gunzip ($READHANDLE, "r");
    $fio->print;
    $fio->close; # or close($READHANDLE);

    But seriously, let us know why Compress::Zlib won't work....

    [url]http://danconia.org[/url]
    Wiggins D Anconia Guest

Similar Threads

  1. Recordset filter question for MySQL
    By Shane930 in forum Coldfusion Database Access
    Replies: 3
    Last Post: May 18th, 09:02 PM
  2. Recordset Filter question - Nested repeat region
    By doc in forum Dreamweaver AppDev
    Replies: 2
    Last Post: July 30th, 03:58 PM
  3. DataRow[] and Select(filter with a like clause) question
    By Ron Vecchi in forum ASP.NET General
    Replies: 2
    Last Post: July 30th, 01:04 PM
  4. Where is gzip?
    By Dallas Haggar in forum AIX
    Replies: 2
    Last Post: July 15th, 10:21 AM
  5. Replies: 1
    Last Post: July 8th, 12:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139