in reply to Trouble making my own open()-like routines.
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trouble making my own open()-like routines.
by William G. Davis (Friar) on Jul 07, 2004 at 23:47 UTC |