Variable Naming [was Re: [] catching $a, $b unnecessary my and maybe other things]

Mikhael Goikhman migo at
Sun Jun 6 13:46:53 PDT 2004

On 06 Jun 2004 22:16:44 +0300, Omer Zak wrote:
> I disagree with the belief that short variable names are better.
> When you use long names, you can grep for all occurrences of a variable 
> in your code.

Yes, long names are better for search and replace (you don't get many
unrelated substrings). But I also personally find them easier to enter.
Such variable may be always copied/pasted using mouse or keyboard.
So in fact I make less typos in long variable names, because it is
tempting to type short names manually.

However for "my" variables, one-two meaningful English words are good.

> If you use 'i', then you would have too many false positives.

Yes, but there is one case when I do use 'i' and 'j' - loops where the
counter is not actually used other than maybe as index, in this case one
should never search for such variable, so there is no false positives.
If the counter is potentially searchable, 'i' is better to be avoided.


perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'

More information about the Perl mailing list