in reply to Re^2: Sub calling sadness
in thread Sub calling sadness

My point is simply that when you use the syntax ThatPackage::blah $foo, perl treats it as a method invocation and expects $foo to look like an 'object' (either a blessed reference or a package name), and this is why the OP is getting the error.

Replies are listed 'Best First'.
Re^4: Sub calling sadness
by ikegami (Patriarch) on Mar 08, 2008 at 17:35 UTC

    My point was that's not true except in the unusual case where the function is not known when the statement is compiled.

    What I didn't catch is that it turns out that's the case here. Because require was used instead of use, blah didn't exist when the ok statement was compiled, therefore Perl assumed the OP was trying to do an indirect method call. The solution is to change the require to a use (or wrap it with a BEGIN) or to use parentheses.

    Omitting parens in Perl is dangerous. Prepare to encounter odd problems once in a while when Perl incorrectly guess what you want to do. One specific rule is that parens (or "&") are REQUIRED when the function isn't declared before it's used.