in reply to Re: On quoting the lhs of '=>'
in thread On quoting the lhs of '=>'

The performance gain from the constant pragma is never going to tip the balance in a real world application
One optimization alone is never going to tip the balance. but imagine how slow perl scripts would be if *everybody* thought like that.
i use a constant to switch on and off debugging in one of my modules, and i compared it to a normal variable, and the difference was big enough for me to use a constant. and as i'm doing benchmarks quite regularly i think i can estimate that.
i'm so tired of all the people saying "don't optimize prematurely" while i have to use several awfully slow tools at work. and slow forums like this one. yes, don't optimize too early, but do it at least at *some* point.
i just don't see why using a constant would be bad at all. trading speed for maintainability is usually not worth it, but what's wrong with a constant. just learn what you have to do if you use it as a hash key and in strings, and that's it.

Replies are listed 'Best First'.
Re^3: On quoting the lhs of '=>'
by perrin (Chancellor) on Jul 10, 2008 at 14:15 UTC
    There are optimizations and there are optimizations. This one isn't worth it, except in special cases. You may have a special case with your debugging example.

    The problem with constant is just what you said: maintainability. Over the years, I have seen so many people have problems with the constant module that I consider it a frequent source of bugs. Yes, if you learn all the details of using it in hashes and strings you can make it work, but people "constantly" stumble over it. It's just too error-prone.

Re^3: On quoting the lhs of '=>'
by BrowserUk (Patriarch) on Jul 10, 2008 at 12:19 UTC