Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Random accessing a gzip file

by grondilu (Pilgrim)
on Oct 17, 2012 at 01:05 UTC ( #999446=note: print w/ replies, xml ) Need Help??


in reply to Random accessing a gzip file

From the manual page of IO::Uncompress::Gunzip, I read:

seek
$z->seek($position, $whence); seek($z, $position, $whence);
Provides a sub-set of the "seek" functionality, with the restriction that it is only legal to seek forward in the input file/buffer. It is a fatal error to attempt to seek backward.
tell
Usage is
$z->tell() tell $z
Returns the uncompressed file offset.

So yes, you can, but of course it can not be as easy as with an uncompressed file.


Comment on Re: Random accessing a gzip file
Select or Download Code
Re^2: Random accessing a gzip file
by pmqs (Monk) on Oct 17, 2012 at 13:13 UTC
    Note that the implementation of seek in IO::Uncompress::Gunzip does not provide true random access to a compressed file. It works by uncompressing data from the current offset in the file/buffer until it reaches the ucompressed offset specified in the parameters to seek. For very small files this may be acceptable behaviour. For large files it may cause an unacceptable delay.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999446]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2014-09-21 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (175 votes), past polls