export constants nicely from perl module...
Wesley Darlington
wesley at yelsew.com
Mon Feb 9 05:16:35 CST 2004
On Fri, Feb 06, 2004 at 11:53:28AM -0800, Michael G Schwern wrote:
> Remember, constants are just subroutines with a prototype of ().
>
> Also, constants have to be declared at compile time in order to be constant,
> but compile time is relative. So...
>
> sub econst {
> my($name, $value) = @_;
> my $caller = caller;
> *{$name} = sub () { $value };
> push @{$caller.'::EXPORT'}, $name;
> }
This is beautiful! Schwern, you rock! :-)
Many thanks,
Wesley.
More information about the Belfast-pm
mailing list