check out inlined DEBUG constant versus $DEBUG. It's discussed there and there's a nice link to a TPJ article. For pure funkiness tho how about:
#!/usr/bin/perl use constant DEBUG_ON => 1; use constant DEBUG_OFF => 0; use vars qw( $DEBUG ); $DEBUG = ( $opt_d eq "y" ) ? DEBUG_ON : DEBUG_OFF;
No? Yeah that's probably too much.
-derby
update: Since I'm not wanting to concentrate on the real job today and since nobody else has pointed it out, the reasoning for the behaviour you describe can be found in perlsub under the section "Constant Functions." Basically, since the constants.pm module defines the constant function with "()", the function is a canidate for inlining and will probably be optimized away by being folded to its value (ie, the sub will never be called).
In reply to Re: change 'use constant' value through commandline arguments?
by derby
in thread change 'use constant' value through commandline arguments?
by neuroball
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |