From 447986c19d2e40536872c4c97c1e5f7a82c29d0d Mon Sep 17 00:00:00 2001 From: Chris C Date: Thu, 9 Feb 2017 09:31:22 -0600 Subject: [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 --- perl.html.markdown | 8 +++----- 1 file 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) { -- cgit v1.2.3