March 2002 Perl Hardware Store 14

2. Manual Importing and Exporting

Constants

         sub import {
           my $name = shift or return;       
           my $value = shift;
           my $caller = caller;
           *{$caller . "::$name"} = sub () { $value };
         }
         use constant PI => 3;
         $circumference = 2 * PI * $r;


Next Copyright © 2002 M-J. Dominus