Currently i am doing something like this
$detail_def{1}{stmt}="\$data{\$key}{sex} eq \"F\" && \$data{\$key}{yr} ==
\$year && \$data{\$key}{INQUIR1} eq \"INQUIR-1\"";
$detail_def{2}{stmt}="\$data{\$key}{sex} eq 'M' && \$data{\$key}{yr}==\$year
&& \$data{\$key}{INQUIR1} eq \"INQUIR-1\"";
> .... several more items
$detail_def{13}{stmt}="\$data{\$key}{sex} eq \"F\" && \$data{\$key}{yr} ==
\$yea
r && (\$data{\$key}{APPLIED} eq \"APPLIED\" || \$data{\$key}{REACTIVA} eq
\"REAC
TIVA\")";
>...... many more items after this
which stores these variables as this
$data{$key}{sex} eq "F" && $data{$key}{yr} == $year && $data{$key}{INQUIR1}
eq "INQUIR-1"
$data{$key}{sex} eq 'M' && $data{$key}{yr}==$year && $data{$key}{INQUIR1} eq
"INQUIR-1"
$data{$key}{sex} eq "F" && $data{$key}{yr} == $year && ($data{$key}{APPLIED}
eq "APPLIED" || $data{$key}{REACTIVA} eq "REACTIVA")
This has been met with success when using code like this......
foreach $item (sort num keys %detail_def){
$count =0;
foreach my $key (sort keys %data){
if (eval $detail_def{$item}{stmt}){
$count++;
}#end eval if
}#end data foreach
...lots more code that handles some other unrelated stuff....
}#end detail foreach
however when i attempt to change
if (eval $detail_def{$item}{stmt}){
to
if (eval $detail_def{$item}{stmt} && $stmt ){
where $stmt is set to $data{$key}{hrs} <= 11
it simply ignores the $stmt bit, same if i use eval $stmt instead, however
later down the line when going on $detail_def{13} and up it works correctly
on checking the $data{$key}{hrs} <= 11 item.
Is there a better way to create dynamic if structures on the fly that i am
not aware of?
Thanks
Wyza
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>