OK, real world example: I give you a sealed envelope with some pages of text, unreadable through the envelope. Your job is to count the number of vowels on the pages, without opening, damaging or otherwise manipulating the envelope.

This is exactly the same problem. You can not process the contents (pages) of a file (envelope) without opening it. It does not matter what kind of file you have: ZIP, gzip, text, HTML, graphics, drawings, XML, photos, ...

Despite the name, gzip (GNU zip) and ZIP (originating from the old PKZIP utility) are completely different things. A ZIP program (like the original PKZIP, WinZIP, InfoZIP, 7ZIP, ...) compresses individual files and creates an archive of them, whereas gzip only compresses files. Even the compression algorithms are different.

gzip files can be decompressed as a stream, i.e. you read a the first few bytes of a gzip file, stuff them into a newly initialised gzip compressor, and get back a few more bytes of content. You stuff some more bytes from the gzip file into the same gzip compressor, and get back the next chunk of bytes. Repeat until EOF. This way, you need only a little bit of memory or temporary disk space, even when processing huge gzip files. bzip2 (again with a completely different algorithm) shares this ability. ZIP archives don't, because (1) a ZIP archive contains more than just a single file and (2) the table of contents is at the END of the ZIP archive.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^5: Question on IO::UnCompress::GunZip... by afoken
in thread Question on IO::UnCompress::GunZip... by biswanath_c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.