Special code blocks such as BEGIN
, CHECK
and END
. They come from Awk, but work differently in Perl, because it is not record-based.
The BEGIN
block can be used to specify some code for the parsing phase; it is also executed when you do the syntax-and-variable-check perl -c
. For example, to load in configuration variables:
BEGIN {
eval {
require 'config.local.pl';
};
if ($@) {
require 'config.default.pl';
}
}