in reply to Uninitialized value in division and Illegal division by zero fix

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!

  • Comment on Re: Uninitialized value in division and Illegal division by zero fix