use v5.14; sub total { my $sum = 0; foreach (@_) { $sum += $_; } say "list @_\nsum is $sum"; $sum; } say "Enter a list of number to calculate sum :"; my @numList = split /[,\s]+/, <STDIN>; chomp @numList; @numList = grep length, @numList; my $total = total(@numList); say "Total : $total"; __END__ Enter a list of number to calculate sum : 10 12 20 list 10 12 20 sum is 42 Total : 42
In reply to Re^7: Use of "my" after Perl v5.14
by Anonymous Monk
in thread Use of "my" after Perl v5.14
by Rohit Jain
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |