laziness, impatience, and hubris | |
PerlMonks |
seek() functionality on pipesby HKS (Acolyte) |
on Jul 21, 2008 at 17:40 UTC ( [id://699086]=perlquestion: print w/replies, xml ) | Need Help?? |
HKS has asked for the wisdom of the Perl Monks concerning the following question: SOLVED: Via the pseek function posted by BrowserUK:
Thanks to all for your help. -------------------------------------Short: Is there a way to achieve seek()-type functionality on pipe output? Long: A project I'm working on reads files from a given offset. For bland text files, this is simple:
However, it also needs to be able to read compressed files. Rather than hardcoding each compression format handler, I'd like to just add a configuration directive that points my program at the appropriate cat tool for the format (zcat, bzcat, whatever happens to be relevant) and open it like this:
But as you all know, I can't seek() on a pipe. How can I work around this? I could dump the output to a file and then read it back in, but this is horribly inefficient and will cause significant performance problems as the files can reach 300-500 MB. Thanks for any help.
Back to
Seekers of Perl Wisdom
|
|