Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1194178]
[davido]: Using the -i switch causes Perl to rename the input file, read from it, and write to a file using the original file's name. If there's an extension provided, as in -i.bak, it's easy to see where the input file is. Where is the input file temporarily....
[davido]: placed if there is no extension provided to the -i switch?

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-09-22 14:48 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (264 votes). Check out past polls.