Next Tricks of the Wizards 44

Read-Only Constants Continued

        use constant PI        => 3,
                     e         => 2.71828182845904523536,
                     emptylist => [];
        package constant;
        sub import {
          my $caller = caller;
          my $package = shift;
          while ($name = shift) {
            my $value = shift;
            *{$caller . '::' . $name} = sub () { $value };
          }
        }


Next Copyright © 2003 M. J. Dominus