Questions about this topic? Sign up to ask in the talk tab.

Perl/Basics/Loops/For Each

From NetSec
Revision as of 03:59, 16 July 2012 by AlizaLorenzo (Talk | contribs) (Created page with "* A foreach loop is built specifically for array handling and iterates through all of the elements in an array. {{code|text=<source lang="perl">my @messages = ("Hello world!\n","...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  • A foreach loop is built specifically for array handling and iterates through all of the elements in an array.
my @messages = ("Hello world!\n","I like perl!\n");
foreach my $message (@messages) {
   print $message;
}
 The above code will iterate through every element in an array.