Perl The syntax format is as follows: Execute the above program, and the output is as follows: foreach loop is used to iterate over the value of a list or collection variable. 5.22.1. Grammar #
foreach var (list) { ... }
5.22.2. Flow chart #

Example #
#!/usr/bin/perl@list=(2,12,36,42,51);# executeforeach circulateforeach$a(@list){print"a's value is:$a\\n";} The value of a is: 2 The value of a is: 12 The value of a is: 36 The value of a is: 42 The value of a is: 51