Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: What does the error 'Illegal division by zero' mean?

by sgifford (Prior)
on May 01, 2004 at 20:42 UTC ( [id://349690]=note: print w/replies, xml ) Need Help??


in reply to What does the error 'Illegal division by zero' mean?

Well, it looks like when the code in $code is evaluated, the length method returns 0, so $n is never incremented, so it's undef when the END block is run. For the purpose of the division, that undef is converted to 0, and there you are---division by 0.

The easiest way to fix this is to check if $n is 0, and if so don't divide by it. The hard part is figuring out what you want to do instead. :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-23 21:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found