I have a script where I am trying to populate a perl hash I can dereference them fine when I do it individually
while(my($key,$value) = each(%{$spec_hash{'XISX'}})) {
print $key, "," .$value ;
print "\n";
}
while(my($key,$value) = each(%{$spec_hash{'XCBO'}})) {
print $key, "," .$value ;
print "\n";
}
However when i just try and dereference the %spec_hash It only containst one $exch reference, while it should had two - the XISX and the XCBO. But it never gets to the XCBO.
#!/sbcimp/dyn/data/EVT/GSD/scripts/perl/bin/perl
use FOOConf; # this is our custom DBI module
use Data::Dumper ;
FOOConf::makeDBConnection(production);
my $dbh=$FOOConf::dbh;
my $query = "select e_risk_symbol from gsd_etds where level_name='EXCH_CS' and e_exch_dest='XISX' and e_symbol_comment in ('Bin_6','Bin_56')";
if(!$dbh) {
print "Error connecting to DataBase; $DBI::errstr\n";
}
my $cur_msg = $dbh->prepare($query) or die "\n\nCould not prepare statement:".$dbh->errstr;
$cur_msg->execute();
while (my @row=$cur_msg->fetchrow_array) {
$spec_hash{'XISX'}{$row[0]}=1;
}
$query = "select e_risk_symbol from gsd_etds where level_name='EXCH_CS' and e_exch_dest='XCBO' and e_combo_type='9999'";
if(!$dbh) {
print "Error connecting to DataBase; $DBI::errstr\n";
}
$cur_msg = $dbh->prepare($query) or die "\n\nCould not prepare statement: ".$dbh->errstr;
$cur_msg->execute();
while (my @row=$cur_msg->fetchrow_array) {
$spec_hash{'XCBO'}{$row[0]}=1;
}
#while(my($key,$value) = each(%spec_hash)) {
# print $key, "," .$value ;
# print "\n";
# }
#
# foreach my $exch (sort keys %spec_hash) {
# print "$exch: $spec_hash{$exch}" ;
# }
print Dumper(\%spec_hash);
this is the dumper - shouldn't the dumper contain the XCBO as well? Why does the hash only have the XISX elements?
$VAR1 = {
'XISX' => {
'FCEL' => 1,
'GPS' => 1,
'MCO' => 1,
'DPZ' => 1,
'WM' => 1,
'SPLS' => 1,
'ILMN' => 1,
'BWLD' => 1,
'CTSH' => 1,
'EWU' => 1,
'MDVN' => 1,
'PDCO' => 1,
'AFAM' => 1,
'SHW' => 1,
}
};