On Oct 5, David Garamond said: >James Edward Gray II wrote: >> Building on this though, if you made the constants module, couldn't you >> make them subs? I believe this is even how the use constant pragma >> functions. Heck make it an object oriented module with static methods >> and it's even designed well. Just a thought. > >good idea. i think i'll use 'use constant' from now on. it's clearer, >$p->constname works, plus i can get rid of the '$' prefix altogether. >thanks!
It's important to know that those "constants" aren't as efficient as their non-method syntax cousins: package FOO; use constant BAR => 10; package main; print FOO::BAR; # at compile-time, Perl makes that 'print 10' print FOO->BAR; # FOO->BAR doesn't become 10 until run-time So you're not saving anything. In fact, I bet THAT is SLOWER than $FOO::BAR. *AND* it won't interpolate (easily) in strings. All the more reasons to use real scalars. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]