I dig the unless caller solution. It is very Perlish. However, here is a very direct comparable solution in Perl:
unless caller
if (__PACKAGE__ eq 'main') { # ...... }