"use constant" is useful for debug statements and levels. In recent versions of Perl, if the compiler can see say "if DEBUG_LEVEL3" and if knows that DEBUG_LEVEL3 is false, that statement will not even be compiled. This can result in a significant performance increase where there are lots of detailed "debug" print statements within an inner loop. Other than that, I think use constant is pretty worthless. I normally use a 'C' style $ALL_UPPER_CASE for constants and as a matter of programming discipline, never use something like that as a lvalue. I guess that was a long winded way of saying: I agree, but think about constant for debug flags when you have a lot of them or they are in performance critical sections of code. | [reply] |