sierrathedog04 has asked for the wisdom of the Perl Monks concerning the following question:
foo; # like foo() if sub foo predeclared, else bareword "foo"One of my scripts is similar to the following:
To my surprise the above code snipped fails. It also fails if I replace 'use' with 'require'. But if I surround the arguments to p with parentheses then it works, i.e.,use CGI; my $q = new CGI; print $q->p "hello world";
If for whatever reasons one wanted to predeclare a member function of a CGI object how would one do that? Clearly, perl does not consider 'use' or 'require' to constitute a predeclaration.use CGI; my $q = new CGI; print $q->p("hello world");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Can One Predeclare a Package's Methods?
by tye (Sage) on May 25, 2001 at 23:41 UTC | |
|
Re: Can One Predeclare a Package's Methods?
by converter (Priest) on May 25, 2001 at 22:22 UTC | |
|
Re: Can One Predeclare a Package's Methods?
by stephen (Priest) on May 25, 2001 at 23:25 UTC | |
|
Re: Can One Predeclare a Package's Methods?
by bikeNomad (Priest) on May 25, 2001 at 22:26 UTC |