Questions about this topic? Sign up to ask in the talk tab.
Difference between revisions of "Perl/Basics/Loops/For"
From NetSec
AlizaLorenzo (Talk | contribs) (Created page with "* A for loop has a built-in counter and stops at a pre-defined number. {{code|text=<source lang="perl">my @messages = ("Hello world!\n","I like perl!\n"); for (my $counter = 0; $...") |
(No difference)
|
Latest revision as of 02:58, 16 July 2012
- A for loop has a built-in counter and stops at a pre-defined number.
my @messages = ("Hello world!\n","I like perl!\n"); for (my $counter = 0; $counter < $#array; ++$counter) { print $messages[$counter]; } |
The above code will iterate through every element in an array.
It is possible to create an infinite loop using for (;;) {...}.