Perl loops- foreach Loop - Perl Scripting

What is Perl foreach loop? What is its function?

The foreach loop iterates over a list value and sets the control variable (var) to be each element of the list in turn −

Syntax

The syntax of a foreach loop in Perl programming language is −

Flow Diagram

foreach_loop(2)

Example

When the above code is executed, it produces the following result −

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Perl Scripting Topics