programming-examples/perl/Subroutine/Passing a range of value to a subroutine.pl

12 lines
178 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
use strict;
total(1, 7, 5, 4, 9);
total(1...10);
sub total {
my $total = 0;
$total += $_ foreach @_;
print "The total is $total\n";
}