Totalling a List : Array Value « Array « Perl
- Perl
- Array
- Array Value
Totalling a List
#!/usr/bin/perl
use warnings;
use strict;
total(1, 107, 105, 114, 9);
total(1...100);
sub total {
my $total = 0;
$total += $_ for @_;
print "The total is $total\n";
}
Related examples in the same category