This question requires an understanding of compiler phase, vs the BEGIN block. From Programming Perl: 3rd Edition - Page 467

It's also important to understand the distinction between compile phase and compile time, and between run phase and run time. A typical Perl program gets one compile phase, and then one run phase. A "phase" is a large-scale concept. But compile time and run time are small-scale concepts. A given compile phase does mostly compile-time stuff, but it also does some run-time stuff via BEGIN blocks. A given run phase does mostly run-time stuff, but it can do compile-time stuff through operators like eval STRING .

Let's take very a simple example

sub complex_sub { die 'code run'; } sleep 5; print 'good'; use constant FOO => complex_sub();

if the above is run as-is, then complex_sub from the users perspective is run in the compiler phase. However, with slight modifications I can have..

# Bar.pm package Bar { use constant FOO => main::complex_sub(); } # test.pl package main { sub complex_sub { die 'code run'; } sleep 5; print 'good'; require Bar; }