Re: [問題]書上了例子不能執行
我猜你沒裝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)
→
08/21 22:16, , 1F
08/21 22:16, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
Perl 近期熱門文章
PTT數位生活區 即時熱門文章