Loops/Foreach: Difference between revisions
Content deleted Content added
Line 957: | Line 957: | ||
A more compact notation using perl statement modifier: |
A more compact notation using perl statement modifier: |
||
<lang perl>print "$_\n" foreach @collection</lang> |
<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}}== |
=={{header|Perl 6}}== |