The only caveat to the use constant pragma is that constants cannot be directly used as keys to a hash table. For example:
#!/usr/bin/perl use warnings; use strict; my %htable = ( 2.7182 => "Euler's constant", PI => "Pi", 1.6180 => "golden ratio", );
This will print "keys = ( 1.618, PI, 2.7182 )" because the word "PI" in the context of a hash key is always interpreted as the string, not the constant symbol.
#!/usr/bin/perl use warnings; use strict; my $x = PI; my %htable = ( 2.7182 => "Euler's constant", $x => "Pi", 1.6180 => "golden ratio", );
This will correctly print "keys = ( 3.14159, 1.618, 2.7182 )" but is not very elegant.