in reply to The Bad, the Ugly, and the Good of autovivification
But the problem is deeper. The problem is using string literals as hash keys, because that more or less turns hash elements into variables - with all the drawbacks of package variables, and then some. If you want a variable, use a (preferably) lexical variable. Don't fall for the sweet lures of "oh, just stuff it into a hash" - it's worse than turning off strict. If you do need to populate a hash, put the index into a constant (with Readonly) or a variable.
Remember the old rule "never put magic numbers inside your program - use constants". But that applies to strings as well. Don't use string literals - use constants. And don't blame autovivification if you do use string literals and burn yourself.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: The Bad, the Ugly, and the Good of autovivification
by tlm (Prior) on Apr 08, 2005 at 13:51 UTC | |
by Anonymous Monk on Apr 08, 2005 at 14:51 UTC | |
by tlm (Prior) on Apr 08, 2005 at 16:26 UTC | |
by Anonymous Monk on Apr 11, 2005 at 09:09 UTC |