in reply to Re^4: Question on IO::UnCompress::GunZip...
in thread Question on IO::UnCompress::GunZip...
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Question on IO::UnCompress::GunZip...
by pmqs (Friar) on Jan 23, 2010 at 19:51 UTC |