在Perl中使用GD :: Graph时的png方法错误

时间:2012-11-02 10:03:39

标签: perl gd-graph

在编译perl脚本以制作图表并将其保存到png文件时,我收到以下错误 - 无法通过包“GD :: Graph :: bars”找到对象方法“png”(也许你忘了加载“GD :: Graph :: bars”?)

知道怎么解决吗?

以下是我的代码 -

use CGI ':standard';
use GD::Graph::bars;
unlink("abc.png");
open (PIC, ">abc.png") or die "an error occurred: $!";
binmode PIC;

my @data = (["Jan", "Feb"],[23, 5]);

my $mygraph = GD::Graph::bars->new(500, 500);

$mygraph->set(
x_label     => 'Month',
y_label     => 'Number of Hits',
title       => 'Number of Hits in Each Month in 2002',) or warn $mygraph->error;

my $myimage = $mygraph->plot(\@data) or die $mygraph->error;

print PIC $mygraph->png;
close(PIC);

由于

1 个答案:

答案 0 :(得分:0)

得到错误 - 打印PIC $ mygraph - > png;我需要使用打印PIC $ myimage - > png;