I'm surprised nobody has mentioned called_as_method from Devel::Caller.
use Devel::Caller qw( called_as_method ); sub new { croak "must call new as method" unless called_as_method(0); ... };
In reply to Re^4: Is "ref($class) || $class" a bad thing?
by adrianh
in thread Is "ref($class) || $class" a bad thing?
by stvn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |