in reply to Re^4: Hash of Hash Redux
in thread Hash of Hash Redux
So in other words, you see these three messages and you don't know what they mean?
You can figure out that lines 53, 54 and 55 are the first three lines after "sub gener". Now, you do have to read a bit about what "my" does in perl, so that you can figure out that in your main "for" loop (over "1 .. $popCt"), the three variables declared there with "my (...)" are not visible (are inaccessible, do not exist) outside the scope of the for loop. Those variables need to be passed to the "gener()" sub as parameters, so that the sub will have access to them, because the "gener" sub is defined outside the scope of the for loop. So do it like this:Global symbol "$refToArrA" requires explicit package name at /tmp/junk +.pl line 53. Global symbol "$refToArrB" requires explicit package name at /tmp/junk +.pl line 54. Global symbol "$refToArrC" requires explicit package name at /tmp/junk +.pl line 55.
That will get rid of the syntax errors (which were imposed because you have "use strict;" at the top). I don't know whether the script does exactly what you want, but it does run, and produces output in a coherent way.for ( 1 .. $popCt ) { my ( $refToArrA, $refToArrB, $refToArrC ) = makeArrays(); &gener( $refToArrA, $refToArrB, $refToArrC ); } # ... sub gener { my ( $refToArrA, $refToArrB, $refToArrC ) = @_; ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Hash of Hash Redux
by BioNrd (Monk) on Nov 01, 2007 at 13:23 UTC | |
by graff (Chancellor) on Nov 03, 2007 at 04:10 UTC | |
by BioNrd (Monk) on Nov 05, 2007 at 01:05 UTC |