
FishMonger
Veteran
Jul 22, 2009, 4:41 PM
Views: 1470
|
|
Re: [efoss] hash of hashes disappears
|
|
|
Here are a few comments on a couple items in your code.
$chromosome_length{1} = 230208; $chromosome_length{2} = 813178; etc That tells me that you should be using an array, not a hash. Whenever you have sequentially numbered hash keys like you're using, you know you used the wrong data structure.
while ($chromosome <= 16) { $genomeLength += $chromosome_length{$chromosome}; $chromosome++; } would be better written as
for my $i (1..16) { $genomeLength += $chromosome_length{$i}; } Whenever you create a filehandle or directory handle, you should ALWAYS check the return code and take action if the open call fails. You should also use a lexical var for the handle and in the case of a filehandle, use the 3 arg form of open. Do not quote single vars. see: perldoc -q quoting
opendir my $DIR, $path or die "opendir failed on '$path' $!";
(This post was edited by FishMonger on Jul 22, 2009, 4:43 PM)
|