Clear questions and runnable code
get the best and fastest answer
SOLVED: Looking for suitable spells to get open to return a filehandle from a moduleby talexb (Chancellor)
|on Nov 28, 2016 at 04:20 UTC
talexb has asked for the wisdom of the Perl Monks concerning the following question:
I'm working on what I imagined would be a simple module to provide versioned access to files (this is something that VMS provides), but it seems I've run up against a challenging (to me) situation with opening files in a module, and passing the file handle back to the caller as open does.
Here's some code that demonstrates the problem:
And the Extra module is here:
The first block works fine, and the second block returns from, but the filehandle is undefined.
I had a good look at the code for File::Temp, and saw where it uses the call to Symbol::gensym for Perls before 5.6, so I tried adding that in. It makes no difference -- I'm using Perl 5.22.1 anyway.
My plan is to hook the call to open and seamlessly handle open a versioned file using the requested file name as a basis -- I've also tried using sysopen, without any success. There's some magic going on that I don't understand.