in reply to Re: BEGIN block question
in thread BEGIN block question
This came up twice very recently. The problem is that the use statements in the BEGIN block finish compiling before the BEGIN block does (seeing as the BEGIN block finishes later in the sources), so they get executed first.
In short, you want
use FindBin qw($RealBin); use lib "$RealBin/lib/"; BEGIN { $ENV{APP_ROOT} = $RealBin; } use MyApp::Conf qw/APP_NAME/;
Previous thread #1
Previous thread #2
|
|---|