#!/perl/bin use v5.14; sub total { local $::@numList = @_; # This line is giving Compiler error.. my $sum = 0; # ForEach is not working in this case.. Even when I use my @numList in declaration.. foreach (@numList) { say "list ", @numList; # Printing 3 (if 1, 2, 3) is input.. say "sum is : $sum"; $sum += $_; } $sum; } say "Enter a list of number to calculate sum :"; my $total = total(chomp(my @numList = )); say "Total : $total";