作者seagal (会长绕跑了)
看板perl
标题Re: [问题]书上了例子不能执行
时间Mon Aug 21 11:06:38 2006
我猜你没装GD::Graph这个模组或没装好
----------------
题外话
perl for bioinformatic
酷喔 呵呵
看来最近越来越多人在用perl做bioinformatic工作了
有心得记得上来分享一下喔:)
※ 引述《rockdan (冻结一切)》之铭言:
: 下面的例子是从Mastering Perl for Bioinformatics这本书来的
: 不知是否有人读过,里面有一个例子,当我测试时却出问题,可是
: 自己也找不出它错哪?或许自己太逊了吧!!
: 我是使用WIN XP系统 ,用ActivePerl 5.8版
: 以下是书的例子:
: #!/usr/bin/perl
: use strict;
: use warnings;
: use Carp;
: use GD::Graph::bars;
: my %dataset=(1=>3,2=>17,3=>34,4=>23,5=>25,6=>20,7=>12,8=>3,9=>1);
: my $graph=new GD::Graph::bars(600,300);
: my ($xmax)=sort{$b<=>$a} keys (%dataset);
: my ($ymax)=sort{$b<=>$a} values (%dataset);
: my $yticks=int($ymax/5)+1;
: my(@xsizes)=(0..$xmax);
: my(@ycounts)=();
: foreach my $x (@xsizes) {if(defined $dataset{$x}){push @ycounts,$dataset{$x};}
: else{push @ycounts,0;}}
: $graph->set(transparent=>0,title=>"summary of mutation data",
: x_label=>'Mutants per cluster',y_label=>'Number of mutant',
: x_all_ticks=>1,y_all_ticks=>0,y_all_numbers=>$yticks,zero_axis=>0,
: zero_axis_only=>0,);
: my $gd=$graph->plot([^xsizes],[^ycounts]);
: my $pngfile= "gdgraph1.png";
: unless(open(PNG,">$pngfile")){croak "Cannot open $pngfile:$!\n";}
: binmode (PNG);
: print PNG $gd->png;
: 在MS-DOS执行下所显示:
: Can't call method "png" on an undefined value at 3.pl line 21.
: 但是在我的perl资料夹中确实有了一个新的图档,只是里面没有写入任何的data
: 不知是哪里出了甚麽问题??
: 请求高手赐教,感恩<(_ _)>
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.109.169.200
※ 编辑: seagal 来自: 140.109.169.200 (08/21 11:06)
※ 编辑: seagal 来自: 140.109.169.200 (08/21 11:07)
1F:→ rockdan:我有装好了,因为别的例子可以执行 08/21 22:16