sub function { # Allow calling as a subroutine or class method shift if ($_[0] eq __PACKAGE__); ... }