in reply to constant and eval (are they enemies?)
It's important that $num here be a closure variable, so that all five coderefs are distinct.BEGIN { no strict 'refs'; for (1..5) { my $num = $_; *{__PACKAGE__ . "::CONSTANT$num"} = sub () { $num }; } }
You should be able to extrapolate this strategy to your application.
-- Randal L. Schwartz, Perl hacker
|
|---|