Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: example

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

in reply to example

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.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: example
by Laurent_R (Canon) 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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2017-11-20 00:39 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (282 votes). Check out past polls.