Questions about this topic? Sign up to ask in the talk tab.
Perl/Basics/Loops/For
From NetSec
(Redirected from Perl for loop)
- 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 (;;) {...}.