in reply to Summing numbers in a file
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
|
|---|