in reply to How to add values of hash by reading from different text files
First, your question is well written. That is one reason you got such a quick response from CountZero.
I am frankly surprised that you have not been taught about my yet. Best practice in Perl programming expects you to use strictures and my/our. Given that this advice is in all of the well known recent Perl training books, your professor is likely to assume that you simply did your homework. If you are concerned, look up a citation and include in in an explanatory note in your code. You can find an appropriate citation in the Camel book or any of the books listed here. "Here" is the Perl page of Larry Wall, the inventor of Perl. You can also probably find a citation even your own textbook. Surely you are allowed to read ahead in your own textbooks?
my declares variables. Strictures are the two lines at the top of CountZero's script: use strict; use warnings; Among other things strictures require you to declare variables (with either my or our) and warn you when you are using variables in ways that you probably shouldn't. Unless you have a very specific (and expert) reason, you should always use these two lines at the top of every script.
Now for how to fix your own code. Your code isn't working because you and your group mate need to use and understand the concepts of Autovivification and Hashes of Hashes. Specifically, relating to your script:
Best, beth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to add values of hash by reading from different text files
by faozhi (Acolyte) on Apr 27, 2009 at 07:34 UTC | |
by CountZero (Bishop) on Apr 27, 2009 at 10:10 UTC |