Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Null values in Perl Calculation

by BillKSmith (Monsignor)
on May 03, 2024 at 15:20 UTC ( [id://11159243]=note: print w/replies, xml ) Need Help??


in reply to Null values in Perl Calculation

Syphilis has identified a special case where this average does not exist. tybalt89 proposed a solution which avoids the error by bypassing the calculation. With this correction, your existing code would output a numeric zero. This may be a problem for your users because they could not tell the difference between an average of zero and no average. I recommend that you ask them what they would prefer. Other possible choices include:
  • Omit record
  • Output a null string
  • Ouput a string of blanks
  • Output a special string ('*****' or '-----')
Except for the first, you could use
$baverage = $baverage1 ? $rec{'BatterRuns'} / $baverage1 : '*****';
Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2026-04-10 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.