|Don't ask to ask, just ask|
Persistence of a filehandle for a large file with varying formatsby seaver (Pilgrim)
|on Jan 25, 2013 at 09:09 UTC||Need Help??|
seaver has asked for the
wisdom of the Perl Monks concerning the following question:
This isn't going to be a very good question as it's 3am, but I'm struggling to make my code flexible as to whether it needs to open a plain text file, or a gzipped file. Thus I have in place this code:
However, my software package (if you can call it that) needs the filehandle itself to be persistent, in order for me to 'seek' back to the beginning multiple times. I'm not able to get my head around this given the two different ways in which I open a file, the normal way, and using IO::Uncompress::Gunzip, which really speaks to my inexperience with I/O (I copied the gunzip section from someplace).
So my question boils down to two things: 1) can I store a persistent filehandle for either a flat file or a gzipped file in the same variable in my package, if so, how? 2) Am I able to 'seek' within a filehandle the same way regardless of the source?
I haven't formulated this very well but will be happy to try and expand further.