We don't bite newbies here... much | |
PerlMonks |
Re: Summing numbers -- onelinerby Discipulus (Canon) |
on Nov 20, 2018 at 10:39 UTC ( [id://1226056]=note: print w/replies, xml ) | Need Help?? |
Hello catfish1116 you already got good answers: a question: why you use state ? I personally never used it and I wonder if is the right thing to do in your example. Anyway I offer you a oneliner (bewere of windows doublequotes!) use CTRL-Z on an empty line to end STDIN input. use CTRL-D on linux:
You also find useful the evil form of eval like in perl -e "push @sum,$_ while $_ = <STDIN> and chomp; print qq(total: ),(eval join '+',@sum),qq(\n)" L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|