http://qs321.pair.com?node_id=305259


in reply to Re: Re: Re: desire to pass file handles by value
in thread desire to pass file handles by value

Nice. It does have negative one side effect, though. If you are reading from some other file (say <STDIN>), and you reference $pos, the tell or seek will change perl's idea of the most recent input file to F. This will mess up the "<STDIN> line n" in any error/warning message, and also change what handle the $. var is looked up in.

To fix this, put a local $.; in STORE and FETCH. (For some reason, this then triggers some warnings from STORE when $pos is localized. Fix by saying seek($pos||0,0)).

If you are downvoting this for other than lack of interest, thanks for sending me a message or reply to let me know why so I can do better (or just stay quiet) next time.