The Perl foreach loop is used to iterate over the values of a list or collection variable.
The syntax format is as follows:
foreach var (list) {...}
Executing the above program, the output result is:
The value of a is: 2a The value is: 12a The value of 36a is: 42a The value of a is: 51