A long time ago, when I started writing Perl, I learned to make constants like this:
*FOO = \"bar";
I know that there is now a constant pragma which is used like this:
use constant FOO => "bar";
But, I never really liked it because you cannot easily interpolate constants in strings using this method:
*FOO = \"BAR";
print qq(\$FOO is set to "$FOO"\n);
use constant FOO => "BAR";
print qq(Constant "FOO" is set to ) . FOO . qq(\n);
Plus, I have a tendency to do this:
use constant FOO => "BAR";
print "The value of FOO is $FOO\n";
However, I know I am in the extremely tiny minority who still use the reference method of making constants, so there must be a major advantage of using the constant pragma that made everyone want to change over.
What are the advantages of the newer constant pragma vs. the older reference method of declaring a constant?