in reply to Using constants...

If I uncomment this line it won't compile because it claims MY_CONSTANT3 is a bareword and not a constant.

Correct. At compile time, there is no function named MY_CONSTANT3, so MY_CONSTANT3 is treated as a string literal. This is obviously not what you want, so strict lets you know.

You need to execute require "constants.pl"; before my $var = MY_CONSTANT3; is compiled.

Since using require to load something that doesn't have a package makes no sense, I'll fix that at the same time.

#!/usr/bin/perl use strict; BEGIN { do "constants.pl"; die $@ if $@; } my $var = MY_CONSTANT3; print "$var\n";

By the way, I removed the exit 1; since there's no reason to signal an error occured.