in reply to use and BEGIN

A simple test of his assumption should be enough to convince:

foo.pm:

package foo; BEGIN { print "foo's BEGIN\n"; } print "foo's body\n"; sub import { shift @_; print "foo's import: @_\n"; } 1;

bar.pm:

package bar; use foo qw(from bar); 1;

test.pl:

use lib '.'; use foo qw(from test.pl); use foo qw(from test.pl again); use bar;

Output:

$ perl test.pl foo's BEGIN foo's body foo's import: from test.pl foo's import: from test.pl again foo's import: from bar $
BEGIN blocks are executed at compilation. use and require don't compile the same code twice.

Look in perlvar under %INC for more info:

The "require" operator uses this hash to determine whether a particular file has already been included.

blokhead