Mega Code Archive

 
Categories / Perl / Array
 

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"; }