Well, you never populate %total_mono in any way (in the code you posted). Therefore, $total_mono{$k} is undefined, no matter what $k contains. And an undefined value is interpreted as zero in a numeric context, and division by zero does not work, of course (see Meaning Of error in perl for a recent discussion).

It's impossible to say how to proceed from here without knowing more about what you want to accomplish.

Also, some general notes:

  1. Please, don't add linenumbers to your code like that; it just makes it syntactically invalid, and monks who want to help will have to remove them again. Please use comments instead.
  2. Even with the line numbers removed, your code doesn't compile due to a missing closing curly brace. Please post working code.
  3. Your code calls a subroutine, process_nuc, that is not included. Please post complete code.
  4. You read from $file1, but we don't know what that file might contain. Please share some sample data.

Here are some more resources on how to ask questions effectively:

Please help us help you. Thanks!


In reply to Re: Uninitialized value in division and Illegal division by zero fix by AppleFritter
in thread Uninitialized value in division and Illegal division by zero fix by To_Bz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.