ibjdt
Programmer
- Nov 25, 2002
- 63
thanks in advance for helping.
i have a DB with columns 0-10.
i also have the following:
i want to look at each item in the hash and compare to DB column 7. if match, update a counter specific to that hash item, then look at each item in the corresponding subtype array versus column 8. if match, update a counter. when both hash items have been compared to each line in the DB - print findings.
i have the code below, and although i get good results for the hash items, i get bad data for the subtypes.
a weird problem also - when i remove the part of the code that looks at the subtypes
it shows zero results?? if i delete only the part that prints out the subtype results, it works fine.
thanks for any suggestions.
i have a DB with columns 0-10.
i also have the following:
Code:
@1 = ("C", "D", "E"); #possible subset of hash item 1
@2 = ("F", "G", "H"); #possible subset of hash item 2
%type = ( 1=>"A", 2=>"B");
i want to look at each item in the hash and compare to DB column 7. if match, update a counter specific to that hash item, then look at each item in the corresponding subtype array versus column 8. if match, update a counter. when both hash items have been compared to each line in the DB - print findings.
i have the code below, and although i get good results for the hash items, i get bad data for the subtypes.
Code:
foreach $key (keys %type)
{
foreach $line(@DB)
{
chomp ($line);
@fields = split(/::/, $line);
if (($fields[5] eq "TBA") && ($fields[7] eq "$type{$key}"))
{
$count[$key]++;
foreach $subtype(@$key)
{
if ($fields[8] eq "$subtype")
{
$count[$subtype]++;
last;
}
}
}
}
}
foreach $key (keys %type)
{
$info{'RESPONSES'} .= "<li>$type{$key} ($count[$key])</li>\n" if ($count[$key]);
foreach $subtype(@$key)
{
if ($count[$subtype])
{
$info{'RESPONSES'} .= "<li>$subtype ($count[$subtype])</li>\n";
}
}
}
a weird problem also - when i remove the part of the code that looks at the subtypes
Code:
foreach $subtype(@$key)
{
if ($fields[8] eq "$subtype")
{
$count[$subtype]++;
last;
}
}
it shows zero results?? if i delete only the part that prints out the subtype results, it works fine.
thanks for any suggestions.