Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: example 7.pl

by choroba (Abbot)
on Aug 05, 2013 at 20:52 UTC ( #1047988=note: print w/ replies, xml ) Need Help??


in reply to example 7.pl

Your post does not contain any question. You are using strict but not declaring your variables, which is the reason of the errors. $a and $b do not have to be declared because they are special - see perlvar.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: example 7.pl
Select or Download Code
Re^2: example 7.pl
by Laurent_R (Vicar) on Aug 05, 2013 at 22:33 UTC

    $a and $b do not have to be declared because they are special

    Which means that they should probably avoided for purposes other than what they are designed and earmarked for (basically sorting operations).

    @Raymond: if you *really* need to use single letter variables, start off with $c, avoid $a and $b. But don't you think it would be better to give meaningful names to your variables? I hold the opinion that giving meaningful names to variables, subroutines, filehandles, etc., is the #1 way of correctly commenting my code. Therefore, asides from quick tests under the debugger, I almost never use one-letter variable, with just one exception: loop variables, i.e. when the variable does not have any other meaning than looping through the subscripts of an array, where I find variable names such as $i, $j and $k to be acceptable. But, whereas using such loop variable is quite common in a language like C (where I come from), it is much less often useful in Perl, in which we can most of the time use better looping constructs (which usually loop directly over the elements, rather than the subscripts, of an array, thereby making meaningful names (the content of the array elements) again possible.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047988]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-08-23 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (168 votes), past polls