tobyperl has asked for the wisdom of the Perl Monks concerning the following question:
The function references in the function hash each do basically the same work other than some simple formatting differences. Each one at the end of its array data collection/creation has the following statement:foreach $key (keys %extractDataFunctionHash) { # Loop over the data in each lines array and extract the specifi +c # data for that sample. Call the function defined for that key. # #printf("calling has function: %s\n", $key); $extractDataFunctionHash{$key}($key, $DNRef, $EDHRef); $numInHash = %$EDHRef; printf("\nPASS: Data extraction complete for %s...%d items in ha +sh.\n", $key, $numInHash); }
When I print out the number of elements in the hash each time in the loop it indicates 1 element, then 1 element, then 2, then 3, then 4, then 5. There should be 6 elements in the hash. I have put printfs all around this line of code. The first function (there are 6 calls to 6 difference functions in the function hash) call adds 1 element in the hash and the number in hash (1) is correct. On the second call, it indicates there is only 1 element in the hash again. Afterwards it increments as it should up to 5 instead of 6. I am totally confused and need help. thanks...$EDHRef->{$key} = \@extractedLinesArray;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: hashes of array references
by davorg (Chancellor) on Jul 22, 2009 at 19:19 UTC | |
by tobyperl (Initiate) on Jul 22, 2009 at 20:24 UTC | |
Re: hashes of array references
by moritz (Cardinal) on Jul 22, 2009 at 19:23 UTC | |
by tobyperl (Initiate) on Jul 22, 2009 at 20:18 UTC |