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

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]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2018-07-22 03:27 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (451 votes). Check out past polls.