in reply to Re: Array Reference Question
in thread Array Reference Question
Can't call method "%s" without a package or object reference (F) You used the syntax of a method call, but the slot filled by the object reference or package name contains an expression that returns a defined value which is neither an object reference nor a package name. Something like this will reproduce the error:I think the error message is ambiguous or somehow it expects $_ to be a reference to an object :s. From what I have read Perl is strictly a 1-time parser. It doesn't scan the file first for subs and then go and compile. In order to be able to call user methods without parentheses you have to predeclare it or define the sub first and then call it last in the file. The latter only works with non-recurisive methods. With recursive obviously you will have to predeclare it. I just tried it and it worked.$BADREF = 42; process $BADREF 1,2,3; $BADREF->process(1,2,3);
I hope it makes sense.
Reference:
http://stackoverflow.com/questions/5992715/why-is-parenthesis-optional-only-after-sub-declaration
http://perldoc.perl.org/perldiag.html
|
|---|