in reply to Re^5: Use of "my" after Perl v5.14
in thread Use of "my" after Perl v5.14
I have this code: -
I can't understand what can be the problem with the code.. I am trying to find the total of some integer from user input..#!/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 @nu +mList 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 = <STDIN>)); say "Total : $total";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Use of "my" after Perl v5.14
by AnomalousMonk (Archbishop) on Sep 21, 2012 at 05:00 UTC | |
Re^7: Use of "my" after Perl v5.14
by Anonymous Monk on Sep 21, 2012 at 00:19 UTC | |
by Rohit Jain (Sexton) on Sep 21, 2012 at 00:28 UTC | |
Re^7: Use of "my" after Perl v5.14
by Anonymous Monk on Sep 21, 2012 at 02:41 UTC |
In Section
Seekers of Perl Wisdom