Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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,

  • Comment on Re: Quick easy question: What does $i mean?

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://494671]
[Corion]: Discipulus: Ouch ... staff cuts are never good, but having to hunt for work isn't great either, especially with a family...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2018-05-23 21:23 GMT
Find Nodes?
    Voting Booth?