in reply to Re^2: Problem passing GD image object
in thread Problem passing GD image object

You would need to pass a reference to the object then update the referenced value:

plot (\$g); ... $$graphimage = $graph->plot(\@data) or die $graph->error;

DWIM is Perl's answer to Gödel