diff options
author | Mark Canlas <github@htmlism.com> | 2015-06-10 00:05:36 +0200 |
---|---|---|
committer | Mark Canlas <github@htmlism.com> | 2015-06-10 00:05:36 +0200 |
commit | 66379e80cdc805612327e71a6cfa79d4699a8186 (patch) | |
tree | 4b61ccb3d7ab0ba9f54a93eed0b7b246bf866263 /perl.html.markdown | |
parent | 75ecb5aa8133325f14d97d00675c3b039da06530 (diff) |
revamped for loops
Diffstat (limited to 'perl.html.markdown')
-rw-r--r-- | perl.html.markdown | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/perl.html.markdown b/perl.html.markdown index ab8c7a32..3c0699ad 100644 --- a/perl.html.markdown +++ b/perl.html.markdown @@ -83,13 +83,23 @@ while (condition) { } -# for and foreach -for ($i = 0; $i <= $max; $i++) { - ... +# for loops and iteration +for (my $i = 0; $i < $max; $i++) { + print "index is $i"; +} + +for (my $i = 0; $i < @elements; $i++) { + print "Current element is " . $elements[$i]; } -foreach (@array) { - print "This element is $_\n"; +for my $element (@elements) { + print $element; +} + +# implicitly + +for (@elements) { + print; } |