in reply to Problems with references using GD::Graph::Data

I assume that you're using warnings and use strict. Are you using?
use diagnostics

Also perhaps you might want to rearrange some of your code so that:

print IMG $gd->gif; if (defined $gd)
becomes
if (defined $gd) { print IMG $gd->gif; } else { ... }
conditional.

metadoktor

"The doktor is in."