in reply to Put multiple values as columns inside a hash

looks like you're data hiding, i.e. using an implicit value of something to then decide what column/month it is. this is generally bad and no longer done in this day and age of cheap storage. so to cut to the chase, make the implicit explicit, i.e. store the column number (or even better month number and/or name) as part of the hash. then you adjust the code to stop relying on implicit order of data. it also opens up avenues of further flexibility, e.g. can summarize data by quarter etc etc.
also just in case the sums of these decimal point numbers really matter using a non floating point math library. typical gotcha is doing a conditional on numbers supposed to add to 100 percent or similar, when in fact floating point math can produce something not quite 100 percent, and the conditional fails. btw for aesthetics, columns of decimal numbers are best decimal point justified..which is a fun little excercise in itself.
cheers.
the hardest line to type correctly is: stty erase ^H
  • Comment on Re: Put multiple values as columns inside a hash

Replies are listed 'Best First'.
Re^2: Put multiple values as columns inside a hash
by buzzybeewhee (Initiate) on Jun 18, 2010 at 07:10 UTC
    Hello

    I'm so sorry, but I'm pretty new to programming, so I'm not exactly sure I got your full idea...

    I'm not exactly letting the value decide what column/month it is...the value is actually the frequency of occurrence of the key in that month.

    And when you say store the column/month/name inside the hash, you mean as the value of the hash? Or the key? I apologize for my ignorance, but I haven't the foggiest idea of how to go about that ><, since they're not exactly the values I need (the values I need are the frequencies of occurrence)

    The last point about decimals is really interesting though :) In the end, I'm going to input the information into an excel file and plot graphs using the data, so this can come into good use :)

    Thank you so much for your helpful input! :D

    Best Regards

    Buzzybee

      sorry for getting back to you late. what i mean is either you need to make the month part of the hash, e.g. assign explicitly $muteperc{$accession}{'month'} = whichever_month_need_to_assign. then when you're doing the output you can easily detect missing month or implicitly show (by printing month). Hope this makes sense.
      in the past i've written a perl report that adds up summary data values, with many different slices of summary results required per month and quarter. rather than counting on particular month data being present, the final output routine was a for(1..12) that indexed into the convoluted hashes by month number. Whatever month indexed values didn't exist (no data) i made sure undef printed as zero.
      on something related in doing summary calculations, can't remember what perl does when you divide by zero...but it ends up being a error with live data when values are missing or contain zero. so always put in an explicit check for divide by zero, before it bites.
      have fun perl coding.
      the hardest line to type correctly is: stty erase ^H