%dbfield = ( 'Edte' => [DATE], 'Ecpp' => [CPP], 'Excdr' => [XCDR], 'Eab' => [ACCESS_BTS, ACCESS_SECTOR, ACCESS_CHANNEL] ); #### foreach $thing (keys %dbfield) { print "the members of $thing are:\n"; foreach (@{$dbfield{$thing}}) { print "\t$_\n"; } } #### #db connect, prepare, exectute goes here.... while($ref = $sth->fetchrow_hashref()) { foreach $opt (@enable_opts) { #@enable_opts is the array of checkbox values #switch statement to perform calculations on values ($ref{'DATE'}) } }