in reply to Re: Sending filehandles?
in thread Sending filehandles?
Better to pass a ref to the glob, \*FH, than *FH. 1) The file handles created by "open my ..." and by things like IO::Handle->new( ... ) are all references to globs so everybody will be getting something that they expect to get. 2) It is a pain to tell *FH from "*FH" and so code that is only slightly naive might not realize that you passed in a file handle (such as code that expects either a handle or a file name).
And, yes, chromatic, I've certainly done that. For one, the "open my ..." trick isn't backward compatible (and doesn't even fail in a way that makes one likely to think "oh, that doesn't work on this version of Perl") and the alternatives that are backward compatible to the oldest deployed Perls in environments I've recently worked in are a bit obnoxious. For another, there are very few problems with using open FOO, ... in relatively small code, thanks in large part to package.
- tye
|
|---|