Just another Perl shrine | |
PerlMonks |
Re: Summing numbers in a fileby kcott (Archbishop) |
on May 30, 2020 at 06:08 UTC ( [id://11117496]=note: print w/replies, xml ) | Need Help?? |
G'day pvfki, "my $sum = eval $numbers;" I'd be extremely wary of doing that as is. Whether through innocent accident or intended maliciousness, using eval on an unknown string could be disasterous. You should include some validation of that input. Perhaps split /[+]/, $numbers then check that every element returned matches the type of number you're going to allow (integer/float; positive/negative; range; and so on). — Ken
In Section
Seekers of Perl Wisdom
|
|