Loops/Foreach: Difference between revisions

m
Line 957:
A more compact notation using perl statement modifier:
<lang perl>print "$_\n" foreach @collection</lang>
 
In perl, it is possible to loop against an explicit list, so there is no need to define a container:
 
<lang perl>foreach $l ( "apples", "bananas", "cherries" ) {
print "I like $l\n";
}</lang>
 
=={{header|Perl 6}}==