I am reading this document to understand the life cycle of a Perl program.
When do run time and when do compile time events occur while running a Perl script on a command line like this:
perl my_script.pl
                perl script.pl will compile script.pl then execute script.pl. Similarly, require Module; will compile Module.pm then execute Module.pm. 
If the compiler encounters a BEGIN block, it will execute the block as soon as the block is compiled. Keep in mind that use is a BEGIN block consisting of a require and possibly a import.
For example,
# script.pl
use Foo;
my $foo = Foo->new();
$foo->do();
Does:
script.pl
use Foo;
require Foo;
Foo.pm
Foo.pm
import Foo;
my $foo = Foo->new();
$foo->do();
script.pl
my $foo = Foo->new();
$foo->do();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With