The first use of 'new' appears before the 'new' sub has been compiled, so perl doesn't know about it yet. It assumes that 'new T' must be an indirect method call on the 'T' class. In the second case, 'new' now exists in the symbol table, so perl assumes you're calling the function 'new' with the parameter 'T', which is a bareword.$ perl -MO=Deparse -e 'sub new { new T } sub s1 { new T }' sub new { 'T'->new; } sub s1 { new 'T'; }
Dave.
In reply to Re: Creating new objects from within a package
by dave_the_m
in thread Creating new objects from within a package
by hawtin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |