Welcome to the wonderful world of anonymous data structures, if you don't already know about it, Data::Dumper is a wonderful module (that comes with the standard distro) for debugging your stuctures to make sure that really have the composition you desire. Example:
Dumper will take a scalar, an array, a hash, references, and more - i find it best to give it references to hashes and arrays instead. Experiment and find out why!use Data::Dumper; print Dumper \%samples;
Also of interest to you might be Using stringified refs for unique IDs?.
Last tip:
The difference is that the $sample in the second snippet is local to the foreach block and goes out of scope when the foreach is finished. Since you aren't using $sample anywhere else it appears, i recommend you use this approach. But, if you do need $sample later in the code, use the first snippet.# these 2 lines my $sample; foreach $sample (@samples) { # are usually better written as foreach my $sample (@samples) {
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)
In reply to (jeffa) 3Re: Hash of refs to refs
by jeffa
in thread Hash of refs to refs
by rje
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |