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