in reply to Running modulino inside BEGIN

If the level is inconsistent, you could check if there's any level with another package.

package Foo; use strict; use warnings; use feature qw( say ); sub is_modulino { for ( my $i = 1; ; ++$i ) { my $caller = caller( $i ); return 1 if !defined( $caller ); return 0 if $caller ne __PACKAGE__; } } BEGIN { say is_modulino() ? 1 : 0; } 1;
$ perl -I . -e'use A;' 0 $ perl A.pm 1

A shorter version could be obtained by unrolling the first two passes of the loop.