in reply to eval use, exported functions, barewords

Before executing your program, Perl needs to compile your source. This happens at "compile time". This basically means that Perl goes through your source code and creates an internal, executable version of your program.

At compile time, no execution takes place except when it encounters a use (or a BEGIN section, but that's not important right now).

When Perl encounters a use, it basically does a require of that module at compile time and executes the "import" subroutine of the module after it has been loaded.

The "import" subroutine of the module that you loaded, usually exports subroutines to your namespace. So, after the use, Perl "knows" that there is a subroutine called "function_from_ModuleA" because of the actions of the "import" subroutine.

So, when Perl continues compiling your program and it encounters a bare word "function_from_ModuleA", it "knows" it is a subroutine and creates the associated internal representation for a subroutine call (without parameters).

Another way that Perl knows at compile time whether a bareword is intended as a subroutine call, is when you prefix it with '&', or if you put a pair of parentheses after it.

So, in your second case, the module has not been loaded yet and so Perl doesn't know what to do with the bareword. You have to provide a hint to Perl that you intend it to be a subroutine call.

Apart from prefixing with '&" or suffixing '()', you can also tell Perl at compile time that there is going to be a subroutien "foo":

sub foo; # note no body specified!

Hope this helps.

Liz