S
Steve
Dear folks
I have a data structure which is an array of hashes of hash
references.
I need to consider each element in turn and retrieve a related set of
values
from a hash of hashes of hashes.
The choppped-down code fragment below should give you the idea.
It seems to work as (I) expected, but what worries is me is that I
realise that I don't actually
understand what I am doing here. When I loop with $each_marker and
$eachDNA the variable I
pull out is a hash ref. I am then using that to provide the key to the
hashes. I could
use some unique component within each pointed-to hash; eg I could
refer
to $pcr_well{$each_marker->{'locus_id'}}{$eachDNA->{'sample_id'}}{plate}
rather than
$pcr_well{$each_marker}{$eachDNA}{plate}. However I would need to be
sure that each will always
point to a unique value and while that is true now, who knows how the
underlying db may change.
Is it safe/sensible to continue to do it like this, I suppose my real
concern is that I don't
have a mental image of what $each_marker and $eachDNA actually *are*
during these loops, will
they suddenly mutate on me ?!
Thanks for any thoughts and advice
foreach my $each_marker (@{$search_result{'markers'}}){
foreach my $eachDNA (@{$search_result{DNA}}){
$pcr_plate_position=$pcr_well{$each_marker}{$eachDNA}{plate};
$pcr_row= $pcr_well{$each_marker}{$eachDNA}{row};
$pcr_col= $pcr_well{$each_marker}{$eachDNA}{col};
print ROBOT qq!$myparams{'pcr_plate_type'}[0]\t
$pcr_plate_position\t$pcr_plate_barcode\t$row_sequence{$pcr_pl_type}[$pcr_row]$pcr_col\t$wash_or_not!;
print ROBOT qq!\t$step: $MM_vol ul $each_marker->{'locus_id'}
master mix into well for DNA $eachDNA->{'DNA'}
$eachDNA->{'Sample_id'}\n!;
}
}
I have a data structure which is an array of hashes of hash
references.
I need to consider each element in turn and retrieve a related set of
values
from a hash of hashes of hashes.
The choppped-down code fragment below should give you the idea.
It seems to work as (I) expected, but what worries is me is that I
realise that I don't actually
understand what I am doing here. When I loop with $each_marker and
$eachDNA the variable I
pull out is a hash ref. I am then using that to provide the key to the
hashes. I could
use some unique component within each pointed-to hash; eg I could
refer
to $pcr_well{$each_marker->{'locus_id'}}{$eachDNA->{'sample_id'}}{plate}
rather than
$pcr_well{$each_marker}{$eachDNA}{plate}. However I would need to be
sure that each will always
point to a unique value and while that is true now, who knows how the
underlying db may change.
Is it safe/sensible to continue to do it like this, I suppose my real
concern is that I don't
have a mental image of what $each_marker and $eachDNA actually *are*
during these loops, will
they suddenly mutate on me ?!
Thanks for any thoughts and advice
foreach my $each_marker (@{$search_result{'markers'}}){
foreach my $eachDNA (@{$search_result{DNA}}){
$pcr_plate_position=$pcr_well{$each_marker}{$eachDNA}{plate};
$pcr_row= $pcr_well{$each_marker}{$eachDNA}{row};
$pcr_col= $pcr_well{$each_marker}{$eachDNA}{col};
print ROBOT qq!$myparams{'pcr_plate_type'}[0]\t
$pcr_plate_position\t$pcr_plate_barcode\t$row_sequence{$pcr_pl_type}[$pcr_row]$pcr_col\t$wash_or_not!;
print ROBOT qq!\t$step: $MM_vol ul $each_marker->{'locus_id'}
master mix into well for DNA $eachDNA->{'DNA'}
$eachDNA->{'Sample_id'}\n!;
}
}