http://www.perlmonks.org?node_id=420620


in reply to When C<use Module;> *not* the same as C<require Module; import Module;>?

You've actually hit on the reason why use is automatically treated as a compile-time directive (i.e., wrapped in a BEGIN{...} block): it alters the parser's syntactic interpretation of code. Specifically, there are places where the same piece of code can have ambiguous syntactic interpretations, depending on whether or not certain symbols are known to be subroutines.

For example, take:

print foo;
If foo is already known by the perl parser to be a subroutine, it will interpret this as meaning:
print(foo());
However, if the interpreter does not know that foo is supposed to be a subroutine, then it will interpret foo to be the name of a file-handle (the indirect argument to print). This is all happening at compile-time (well, parse-time, really... but parse and compile happen together), so it doesn't matter whether or not foo is a subroutine at runtime... because the parser will have already decided that it was being used as the name of a filehandle, at runtime.
------------ :Wq Not an editor command: Wq