Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Quick easy question: What does $i mean?

by kirbyk (Friar)
on Sep 23, 2005 at 20:53 UTC ( #494671=note: print w/ replies, xml ) Need Help??


in reply to Quick easy question: What does $i mean?

Additionally, it's a long-standing tradition (from early versions of Fortran, if I know my history correctly) to name loop control variables starting with $i (and $j and $k for nested loops.)
It's generally considered highly bad form to have such undescriptive variable names, but small loops (less than 10 lines) tend to not be so bad to figure it out, and it's idiomatic. Everyone has always used $i for that, since the Dawn Of Time, before you had as much control over what to name your variables.
But it's not a special perl variable at all. You could change it to $loop_counter everywhere, and it'd work just fine.

-- Kirby, WhitePages.com


Comment on Re: Quick easy question: What does $i mean?
Re^2: Quick easy question: What does $i mean?
by spiritway (Vicar) on Sep 24, 2005 at 04:44 UTC

    It goes back to mathematics, which often uses i, j, k for indexes in summations and arrays, matrices, and such...

      Actually it goes back to Fortran where variables starting with the letters i-n (INteger) are integer and (I think all) others are real by default.


      Perl is Huffman encoded by design.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2014-09-22 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls