Mega Code Archive

 
Categories / Perl / Subroutine
 

Passing a range of value to a subroutine

#!/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"; }