summaryrefslogtreecommitdiffhomepage
path: root/perl.html.markdown
diff options
context:
space:
mode:
authorChris C <centreti@users.noreply.github.com>2017-02-09 09:31:22 -0600
committerven <vendethiel@hotmail.fr>2017-02-09 16:31:22 +0100
commit447986c19d2e40536872c4c97c1e5f7a82c29d0d (patch)
tree11a81ac13eb805ba5f9d7b111af3035b3dc54892 /perl.html.markdown
parent4e6d0775566f332f78ac3b334533ca18eeb96e4a (diff)
[perl/en] more perlish iterations on perl5 (#2489)
* more perlish iteration c-style 'for' isn't perlish * Update perl.html.markdown removed one of the array iterator loops
Diffstat (limited to 'perl.html.markdown')
-rw-r--r--perl.html.markdown8
1 files changed, 3 insertions, 5 deletions
diff --git a/perl.html.markdown b/perl.html.markdown
index a29fdf1f..93eabea9 100644
--- a/perl.html.markdown
+++ b/perl.html.markdown
@@ -138,18 +138,16 @@ while (condition) {
# for loops and iteration
-for (my $i = 0; $i < $max; $i++) {
+for my $i (0 .. $max) {
print "index is $i";
}
-for (my $i = 0; $i < @elements; $i++) {
- print "Current element is " . $elements[$i];
-}
-
for my $element (@elements) {
print $element;
}
+map {print} @elements;
+
# implicitly
for (@elements) {