in reply to Bloated code of loops and conditionals

Just a thought, but instead of the series of if statements, why don't you make a hash with keys $sqldata->[$i]{'goal'}?