Blob


1 #!/usr/bin/perl
3 #Using the subroutine from the previous problem, make a program to calculate the sum of the numbers from 1 to 1,000
5 use warnings;
6 use strict;
7 use utf8;
9 sub total {
10 my $sum = 0;
11 foreach (@_) {
12 $sum += $_;
13 }
14 return $sum;
15 }
17 print "The sum from 1 to 1000 is ". total(1..1000)."\n";