Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: use strict won't require explicit name for all variables?

by Dog and Pony (Priest)
on Feb 28, 2002 at 19:13 UTC ( #148334=note: print w/replies, xml ) Need Help??

in reply to use strict won't require explicit name for all variables?

The reasons for this is already thouroughly explained, so I just want to add a word of "wisdom"... or something.

In any programming generally, you should really use describing variables, because, much like "use strict", it will save you a lot of grief down the road. In perl, specifically, it also makes sure you don't clash with any special variables. Most of the time, people just don't name their variables $" or $\, even when not being verbose, so it is rarely a problem - apart from a few cases like this one.

I do understand that this was only test code, but it doesn't hurt to use names like $first_element and $second_element or something, anyways. And, use lowercase variable names, so it will never clash with for example the names from "use English".

You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Replies are listed 'Best First'.
Re: Re: use strict won't require explicit name for all variables?
by Biker (Priest) on Feb 28, 2002 at 21:22 UTC

    OK. Agreed. 100%.

    But I can't stop myself from thinking that there might or will be situations where $a and $b may be meaningful.

    In a Windows specific application, when accessing diskette drives A: and B: it wouldn't be very far fetched to name two variables $a and $b. If I already know that it's a bad thing I wouldn't do it. But someone who doesn't know about the special meaning of $a and $b could find it quite natural to use those variable names in this situation.

    Personally, I have today learnt about $a and $b for life. But if I could be unaware of their special meaning, many more people will. My co-worker, who definitively is a Perl beginner, had no way of understanding the behavior on his own.

    Everything will go worng!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://148334]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-06-23 20:58 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.