Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Could someone tell me why constant is preferable to #define in the following code? Perhaps in the case you've shown, they're more or less equivalent, but as things grow more complex, the benefits of using constant instead start to show up. Constants are scoped to Perl packages, not to a source file, which minimizes namespace conflicts:
You can also define constant references to an array or hash:
Of course, there's tricks you can pull with pre-processor macros that go beyond what use constant can do, but for simple cases like the one you show, I'd encourage you to standardize on constant instead. In reply to Re: C pre-processor in Perl
by simonm
|
|