aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-100/mohammad-anwar/perl/ch-2.pl10
1 files changed, 3 insertions, 7 deletions
diff --git a/challenge-100/mohammad-anwar/perl/ch-2.pl b/challenge-100/mohammad-anwar/perl/ch-2.pl
index 3c656996b1..6c62dab8da 100644
--- a/challenge-100/mohammad-anwar/perl/ch-2.pl
+++ b/challenge-100/mohammad-anwar/perl/ch-2.pl
@@ -14,11 +14,7 @@ sub sum {
my ($t) = @_;
my $i = 0;
- my $s = [@{shift @$t}];
- push @$s, ($_->[$i] > $_->[$i+1])?($i+=2 and $_->[--$i]):($_->[$i]) for @$t;
-
- my $sum = 0;
- $sum += $_ for @$s;
-
- return $sum;
+ my $s = (@{shift @$t})[0];
+ $s += ($_->[$i] > $_->[$i+1])?($i+=2 and $_->[--$i]):($_->[$i]) for @$t;
+ return $s;
}