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

Perl/Basics/Loops/For Each

From NetSec
(Redirected from Perl foreach)
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.