Small problem is that these are package variables (not 'my'-able). Under 'use strict' U have to 'our' them. In case U want the freedom to choose between package or lexical, I use this:
use CONSTANT;
CONSTANT my $E => 2.73,
my $PI => 3.14,
my $CREDO => 'The dream of the slave is...to become master
+and have slaves';
# Oops! Wrong CREDO ;)
$CREDO = 'In $$$ we trust!'; # will ERROR out ;)
# and U can:
print "I still believe that '$CREDO!'\n";
#where
package CONSTANT;
use Carp;
use Exporter;
use Tie::Scalar;
@ISA = qw(Tie::StdScalar Exporter);
@EXPORT = qw(CONSTANT);
# sub CONSTANT {my $i=0;tie $_[$i++],__PACKAGE__,$_[$i++] while $i<@_}
sub CONSTANT {tie $_[$.++],__PACKAGE__,$_[$.++] while $. < @_}
# If you want to know if something is tied somewhere ;)
# sub REF {@_ > 1 ? '' : ref tied $_[0] || ref $_[0]}
sub STORE {confess "constants are READ ONLY!"};
1;
vess