Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Argument "" isn't numeric in division (/)

by sundialsvc4 (Abbot)
on Jul 04, 2017 at 23:51 UTC ( #1194178=note: print w/replies, xml ) Need Help??


in reply to Argument "" isn't numeric in division (/)

If a parameter (hash key) might not exist, then the exists() function should be used to test for this possibility.   Unlike defined(), this function will check to see if the key exists, no matter what the associated value is.   (A key containing the value undef exists, but it is not defined.)

Incidentally, if the parameter truly is “optional,” I would recommend that the caller should omit the parameter entirely, rather than provide any sort of sentinel value – e.g. undef or zero – in its place.   exists() will then be able to tell you if the parameter was provided or not.   Should you find that the value exists but that it is nonsensical, I recommend that your routine should throw an exception.

  • Comment on Re: Argument "" isn't numeric in division (/)

Replies are listed 'Best First'.
Re^2: Argument "" isn't numeric in division (/)
by Anonymous Monk on Jul 05, 2017 at 02:44 UTC

    If a parameter (hash key) might not exist,

    The OP isn't using a hash , sundialsvc4 you don't know anything about perl programming

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1194178]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-11-17 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (270 votes). Check out past polls.

    Notices?