On Jan 18, 11:06 pm, [EMAIL PROTECTED] (Kevin Viel) wrote: > This I cannot get my mind around... > > My data: > > SNP Genotype > 1 CC > 1 CT > 1 TT > 1 NN > > It seems to me that I need a hash of hashes. > > Inner hash: > > $inner{ $Genotype }++ ; > > Since the value of the out hash ( $outer{ $SNP } ) has to be a scalar, this > scalar has to be a reference to the inner hash, correct? If so, how do I > declare them? > > my %outer ; > > Or should it be a reference to an anonymous hash? > > my $outer = +{} ;
>From what you've told us so far there is nothing to pick or choose between the two. Both will work perfectly well. It's largely a matter of personal taste (TIMTOWTDI). > So that my code might look like: > > $outer -> { $SNP }{ $Genotype }++ ; And, if you'd declared a hash named %outer, it would look like: $outer{ $SNP }{ $Genotype }++ ; > Any help or reference is appreciated. If you are planning to pass you outer hash into subroutines as an argument then using $outer={} has an advantage over %outer in so far as the code inside and outside the subroutines will look similar (in that it'll all have -> operators). This is both aesthetically pleasing[1] and may also aid maintainability. [1] Which gives me a chance to plug this year's YAPC::Europe "Beautiful Perl" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/