CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [efoss] hash of hashes disappears: Edit Log



FishMonger
Veteran / Moderator

Jul 22, 2009, 4:41 PM


Views: 2035
Re: [efoss] hash of hashes disappears

Here are a few comments on a couple items in your code.


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.


Code
while ($chromosome <= 16) { 
$genomeLength += $chromosome_length{$chromosome};
$chromosome++;
}

would be better written as

Code
for my $i (1..16) { 
$genomeLength += $chromosome_length{$i};
}



Code
opendir (DIR, "$path");

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


Code
opendir my $DIR, $path or die "opendir failed on '$path' $!";



(This post was edited by FishMonger on Jul 22, 2009, 4:43 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Jul 22, 2009, 4:43 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives