in reply to Re: Trouble making my own open()-like routines.
in thread Trouble making my own open()-like routines.

You really should be using lexical filehandles instead of bareword filehandles, especially if you're passing things around. That aside, you can solve your problem by either declaring the test sub before the print statement, or by using &test() to disambiguate the sub call.

Yeah, I suppose I shouldn't be using those bareworded file handles. Predeclaring or just not using subroutines in conjunction with print isn't a huge deal as these two open*() routines belong to a specific Perl application coded by me, not some public Perl module, so a less-flexible interface is acceptable.

Apparently the compiler keeps track of earlier open BAREWORD statements to hint to the compiler that the bareword refers to a filehandle. I believe that's why changing to a normal open works fine.

That's not fair! :(

  • Comment on Re^2: Trouble making my own open()-like routines.