Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Summing numbers in a file

by kcott (Archbishop)
on May 30, 2020 at 06:08 UTC ( [id://11117496]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11117496]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found