The PBP suggests suffixing reference variables with _ref. The book notes in a footnote that this is the only type of “Hungarian notation” suggested in the book. That’s good, because Hungarian notation is a bad idea.
I don’t agree with this. Firstly, it makes a lot of variable names needlessly longer.
Secondly, if you have strict and warnings on, it will complain. There’s no reason to clutter your code because you might possibly forget something sometime.
Thirdly, with current Perls, several of the things you’ll do no longer need the dereference – keys, for instance.
If, as I suggested in another comment, you always use references for hashes and arrays, you don’t have the “what kind was this” problem, either. It’s always a reference.
I don’t do this, and will resist the suggestion to doing so. It is a waste of the programmer’s time and energy, and distracts from what your code is trying to do to make up for a perceived weakness in the interpreter.
Tags: perl programming