Every Now and Then Perl Bites You in the Ass

Supposing you want to use a constant, for all the usual reasons, to configure the name of an environment variable you need to check.  So, you say


Then, you use it to check existence and pull up the value of the variable

my $dangerEnvVar = $ENV{DANGERENV};

Anybody see this coming without previous experience being bitten on the ass by it?

So far as I can tell, the all-caps bareword in {} gets treated as a literal, rather than expanded as a constant; so it looks for environment variable DANGERENV, not RUN_DANGEROUS_TESTS. And fails to find it, of course. Oops! Perl is sometimes just slightly too smart for its own good.