in reply to managing constants created with constant.pm
You are using the constant.pm pragmatic incorrectly, and constants don't do what you think they do.
Correct syntax is,
which produces constant subs of the form sub SCROLL_X () { 1;}. The prototype is important there, because it is a hint to the perl compiler that it may optimize away the sub call by replacing it with the constant value. There is no runtime reminant of the sub or its name.use constant SCROLL_X => 1; use constant SCROLL_Y => 2; use constant FLOW_X => 3; use constant FLOW_Y => 4;
Update: As Abigail-II notes, recent constant.pm can take a hashref as argument. The syntax
is fine if older versions need not be supported.use canstant { SCROLL_X => 1, SCROLL_Y => 2, FLOW_X => 3, FLOW_Y => 4, };
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: managing constants created with constant.pm
by Abigail-II (Bishop) on Jul 14, 2003 at 08:39 UTC | |
by Zaxo (Archbishop) on Jul 14, 2003 at 08:50 UTC | |
by Abigail-II (Bishop) on Jul 14, 2003 at 08:57 UTC | |
by bakunin (Scribe) on Jul 14, 2003 at 09:16 UTC | |
by thinker (Parson) on Jul 14, 2003 at 09:36 UTC | |
by bakunin (Scribe) on Jul 14, 2003 at 09:29 UTC |