print's prototype is extremely complicated to begin with. I think there are three ways to interpret a statement like this:
When the compiler gets to this point, it has no prior hints about FOO or test. It guesses indirect object notation -- not a horrible guess when two consecutive tokens are barewords. 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. Declaring the sub test before the open statement hints to the compiler that test as a bareword refers to a sub, not a class name. Using &test() is also unambiguously a call to a subroutine. (You can always see which syntax the compiler chose by using Deparse)print FOO test();
I believe this is one of the reasons tye often speaks out strongly against /^[a-z]+$/ function names. You've shown that the compiler doesn't always get it right. Update: This particular problem still happens if you rename test to Te_st...
blokhead
In reply to Re: Trouble making my own open()-like routines.
by blokhead
in thread Trouble making my own open()-like routines.
by William G. Davis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |