なんだか

なんだかグラフが描きたい気分になったので、ppm installとかしてみる。

C:\Documents and Settings\rinta>ppm install GD
Downloading ActiveState Package Repository packlist...not modified
Downloading GD-2.35...done
Unpacking GD-2.35...done
Generating HTML for GD-2.35...done
Installing to site area...done
  20 files installed

C:\Documents and Settings\rinta>

あっけなく終了。この間のPlaggerの悪夢は何だったんだ。
・・・嘘でした。GDは入ったけど、その下のGraphとかが入ってないや。次に試したコマンドはこれ。

C:\Documents and Settings\rinta>perl -MCPAN -e "install GD::Graph"
CPAN: Storable loaded ok
Going to read C:\Perl\cpan\Metadata
  Database was generated on Tue, 24 Jul 2007 09:51:48 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/01mailrc.txt.gz
Going to read C:\Perl\cpan\sources\authors\01mailrc.txt.gz
Fetching with LWP:
  http://ppm.activestate.com/CPAN/modules/02packages.details.txt.gz
Going to read C:\Perl\cpan\sources\modules\02packages.details.txt.gz
  Database was generated on Tue, 07 Aug 2007 07:50:55 GMT

  There's a new CPAN.pm version (v1.9102) available!
  [Current version is v1.7602]
  You might want to try
    install Bundle::CPAN
    reload cpan
  without quitting the current session. It should be a seamless upgrade
  while we are running...

Fetching with LWP:
  http://ppm.activestate.com/CPAN/modules/03modlist.data.gz
Going to read C:\Perl\cpan\sources\modules\03modlist.data.gz
Going to write C:\Perl\cpan\Metadata
Running install for module GD::Graph
Running make for B/BW/BWARFIELD/GDGraph-1.44.tar.gz
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/B/BW/BWARFIELD/GDGraph-1.44.tar.gz
CPAN: Digest::MD5 loaded ok
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/B/BW/BWARFIELD/CHECKSUMS
Checksum for C:\Perl\cpan\sources\authors\id\B\BW\BWARFIELD\GDGraph-1.44.tar.gz
ok
Scanning cache C:\Perl/cpan/build for sizes
CPAN: Archive::Tar loaded ok
GDGraph-1.44/
GDGraph-1.44/samples/
GDGraph-1.44/samples/sample15.pl
GDGraph-1.44/samples/sample22.pl
GDGraph-1.44/samples/sample18.pl
GDGraph-1.44/samples/sample41.pl
GDGraph-1.44/samples/sample57.pl
GDGraph-1.44/samples/sample53.pl
GDGraph-1.44/samples/sample21.pl
GDGraph-1.44/samples/sample94.pl
GDGraph-1.44/samples/sample55.pl
GDGraph-1.44/samples/save.pl
GDGraph-1.44/samples/sample23.pl
GDGraph-1.44/samples/sample51.pl
GDGraph-1.44/samples/sample61.pl
GDGraph-1.44/samples/sample63.pl
GDGraph-1.44/samples/sample19.pl
GDGraph-1.44/samples/sample54.pl
GDGraph-1.44/samples/sample52.pl
GDGraph-1.44/samples/sample42.dat
GDGraph-1.44/samples/sample64.pl
GDGraph-1.44/samples/sample16.pl
GDGraph-1.44/samples/rgb.txt
GDGraph-1.44/samples/logo.png
GDGraph-1.44/samples/sample95.pl
GDGraph-1.44/samples/sample71.pl
GDGraph-1.44/samples/sample13.pl
GDGraph-1.44/samples/sample14.pl
GDGraph-1.44/samples/Makefile
GDGraph-1.44/samples/sample31.pl
GDGraph-1.44/samples/sample62.pl
GDGraph-1.44/samples/sample91.pl
GDGraph-1.44/samples/sample92.pl
GDGraph-1.44/samples/sample1A.pl
GDGraph-1.44/samples/sample1B.pl
GDGraph-1.44/samples/sample12.pl
GDGraph-1.44/samples/sample56.pl
GDGraph-1.44/samples/sample93.pl
GDGraph-1.44/samples/sample11.pl
GDGraph-1.44/samples/sample54.dat
GDGraph-1.44/samples/sample42.pl
GDGraph-1.44/samples/sample17.pl
GDGraph-1.44/t/
GDGraph-1.44/t/images/
GDGraph-1.44/t/images/logo.xbm
GDGraph-1.44/t/images/logo_gif_noext
GDGraph-1.44/t/images/logo.jpeg
GDGraph-1.44/t/images/logo.gif
GDGraph-1.44/t/images/logo.jpg
GDGraph-1.44/t/images/logo_ping_noext
GDGraph-1.44/t/images/logo.xpm
GDGraph-1.44/t/images/logo_alt.PNG
GDGraph-1.44/t/images/logo_xpm_noext
GDGraph-1.44/t/images/logo.png
GDGraph-1.44/t/images/logo_jpeg_noext
GDGraph-1.44/t/images/logo_xbm_noext
GDGraph-1.44/t/data.tab
GDGraph-1.44/t/axestype.t
GDGraph-1.44/t/error.t
GDGraph-1.44/t/use.t
GDGraph-1.44/t/colour.t
GDGraph-1.44/t/data.csv
GDGraph-1.44/t/data.t
GDGraph-1.44/t/bugfixes.t
GDGraph-1.44/MANIFEST
GDGraph-1.44/Dustismo_Sans.ttf
GDGraph-1.44/Graph/
GDGraph-1.44/Graph/Error.pm
GDGraph-1.44/Graph/Data.pm
GDGraph-1.44/Graph/area.pm
GDGraph-1.44/Graph/axestype.pm
GDGraph-1.44/Graph/hbars.pm
GDGraph-1.44/Graph/pie.pm
GDGraph-1.44/Graph/bars.pm
GDGraph-1.44/Graph/colour.pm
GDGraph-1.44/Graph/FAQ.pod
GDGraph-1.44/Graph/lines.pm
GDGraph-1.44/Graph/linespoints.pm
GDGraph-1.44/Graph/utils.pm
GDGraph-1.44/Graph/points.pm
GDGraph-1.44/Graph/mixed.pm
GDGraph-1.44/Graph.pm
GDGraph-1.44/README
GDGraph-1.44/CHANGES
GDGraph-1.44/META.yml
GDGraph-1.44/Dustismo.LICENSE
GDGraph-1.44/Makefile.PL

  CPAN.pm: Going to build B/BW/BWARFIELD/GDGraph-1.44.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite GD::Text 0.80 not found.
Writing Makefile for GD::Graph

The automatic tests for GDGraph are not really a solid workout of the
library. The best way to test the package is to run the examples
before installing it.  You can run the examples in the samples
directory with `make samples` or by going into that directory, and
just running `make`.
If that fails, please read samples/Makefile.
        • Unsatisfied dependencies detected during [B/BW/BWARFIELD/GDGraph-1.44.tar.g
z] ----- GD::Text Shall I follow them and prepend them to the queue of modules we are processing right now? [yes] Running make test Delayed until after prerequisites Running make install Delayed until after prerequisites Running install for module GD::Text Running make for M/MV/MVERB/GDTextUtil-0.86.tar.gz Fetching with LWP: http://ppm.activestate.com/CPAN/authors/id/M/MV/MVERB/GDTextUtil-0.86.tar.gz Fetching with LWP: http://ppm.activestate.com/CPAN/authors/id/M/MV/MVERB/CHECKSUMS Checksum for C:\Perl\cpan\sources\authors\id\M\MV\MVERB\GDTextUtil-0.86.tar.gz o k GDTextUtil-0.86/ GDTextUtil-0.86/Text.pm GDTextUtil-0.86/t/ GDTextUtil-0.86/t/align.t GDTextUtil-0.86/t/lib.pl GDTextUtil-0.86/t/text.t GDTextUtil-0.86/t/wrap.t GDTextUtil-0.86/demo/ GDTextUtil-0.86/demo/GDWrap.pl GDTextUtil-0.86/demo/GDWrap.ref.png GDTextUtil-0.86/MANIFEST GDTextUtil-0.86/Makefile.PL GDTextUtil-0.86/Dustismo_Sans.ttf GDTextUtil-0.86/Text/ GDTextUtil-0.86/Text/Wrap.pm GDTextUtil-0.86/Text/Align.pm GDTextUtil-0.86/Changes GDTextUtil-0.86/Dustismo.LICENSE GDTextUtil-0.86/README CPAN.pm: Going to build M/MV/MVERB/GDTextUtil-0.86.tar.gz Checking if your kit is complete... Looks good Writing Makefile for GD::Text Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cp Text.pm blib\lib\GD\Text.pm cp Text/Wrap.pm blib\lib\GD\Text\Wrap.pm cp Text/Align.pm blib\lib\GD\Text\Align.pm nmake -- OK Running make test Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'bl ib\lib', 'blib\arch')" t/*.t t/align....ok 5/21 skipped: Some TTF tests disabled: Freetype inconsistent t/text.....ok 6/20 skipped: various reasons t/wrap.....ok 2/14 skipped: Some TTF tests disabled: Freetype inconsistent All tests successful, 13 subtests skipped. Files=3, Tests=55, 1 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00 CPU) nmake test -- OK Running make install Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. Installing C:\Perl\html\site\lib\GD\Text.html Installing C:\Perl\html\site\lib\GD\Text\Align.html Installing C:\Perl\html\site\lib\GD\Text\Wrap.html Installing C:\Perl\site\lib\GD\Text.pm Installing C:\Perl\site\lib\GD\Text\Align.pm Installing C:\Perl\site\lib\GD\Text\Wrap.pm Writing C:\Perl\site\lib\auto\GD\Text\.packlist Appending installation info to C:\Perl\lib/perllocal.pod nmake install -- OK Running make for B/BW/BWARFIELD/GDGraph-1.44.tar.gz Is already unwrapped into directory C:\Perl\cpan\build\GDGraph-1.44 CPAN.pm: Going to build B/BW/BWARFIELD/GDGraph-1.44.tar.gz Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cp Graph.pm blib\lib\GD\Graph.pm cp Graph/Error.pm blib\lib\GD\Graph\Error.pm cp Graph/utils.pm blib\lib\GD\Graph\utils.pm cp Graph/axestype.pm blib\lib\GD\Graph\axestype.pm cp Graph/lines.pm blib\lib\GD\Graph\lines.pm cp Graph/points.pm blib\lib\GD\Graph\points.pm cp Graph/hbars.pm blib\lib\GD\Graph\hbars.pm cp Graph/linespoints.pm blib\lib\GD\Graph\linespoints.pm cp Graph/bars.pm blib\lib\GD\Graph\bars.pm cp Graph/Data.pm blib\lib\GD\Graph\Data.pm cp Graph/area.pm blib\lib\GD\Graph\area.pm cp Graph/pie.pm blib\lib\GD\Graph\pie.pm cp Graph/colour.pm blib\lib\GD\Graph\colour.pm cp Graph/mixed.pm blib\lib\GD\Graph\mixed.pm cp Graph/FAQ.pod blib\lib\GD\Graph\FAQ.pod nmake -- OK Running make test Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'bl ib\lib', 'blib\arch')" t/*.t t/axestype....ok t/bugfixes....ok t/colour......ok t/data........ok t/error.......ok t/use.........ok All tests successful. Files=6, Tests=118, 1 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00 CPU) nmake test -- OK Running make install Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. Installing C:\Perl\html\site\lib\GD\Graph.html Installing C:\Perl\html\site\lib\GD\Graph\colour.html Installing C:\Perl\html\site\lib\GD\Graph\Data.html Installing C:\Perl\html\site\lib\GD\Graph\Error.html Installing C:\Perl\html\site\lib\GD\Graph\FAQ.html Installing C:\Perl\html\site\lib\GD\Graph\hbars.html Installing C:\Perl\site\lib\GD\Graph.pm Installing C:\Perl\site\lib\GD\Graph\area.pm Installing C:\Perl\site\lib\GD\Graph\axestype.pm Installing C:\Perl\site\lib\GD\Graph\bars.pm Installing C:\Perl\site\lib\GD\Graph\colour.pm Installing C:\Perl\site\lib\GD\Graph\Data.pm Installing C:\Perl\site\lib\GD\Graph\Error.pm Installing C:\Perl\site\lib\GD\Graph\FAQ.pod Installing C:\Perl\site\lib\GD\Graph\hbars.pm Installing C:\Perl\site\lib\GD\Graph\lines.pm Installing C:\Perl\site\lib\GD\Graph\linespoints.pm Installing C:\Perl\site\lib\GD\Graph\mixed.pm Installing C:\Perl\site\lib\GD\Graph\pie.pm Installing C:\Perl\site\lib\GD\Graph\points.pm Installing C:\Perl\site\lib\GD\Graph\utils.pm Writing C:\Perl\site\lib\auto\GD\Graph\.packlist Appending installation info to C:\Perl\lib/perllocal.pod nmake install -- OK C:\Documents and Settings\rinta>

うん、入った。で、試すのは次のコード。

use strict;

use GD::Graph::bars; 

my @xLabels  = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my @data2002 = qw(  17  19  26  38  56  64  67  53  40  29  21  13 );
my @data2003 = qw(  19  24  27  41  56  69  75  60  44  33  22  15 );
my @data     = ( \@xLabels, \@data2002, \@data2003 );

my $graph = GD::Graph::bars->new( 800, 600 );

$graph->set( title   => "Rainfall 2002/2003",
             y_label => "Millimetres" );

my $image = $graph->plot( \@data ) or die( "Cannot create image" );

open( OUT, "testgraph.png") or die( "Cannot display image: $!" );
#Two-data-set bar chart 	
binmode OUT;
print OUT $image->png();
close OUT;

普通に終了。でも、ファイルが出来ていない。なんで?:; 分かった、出力ファイルである事をPerlに教えてやっていない。openのところはコレが正解。

open( OUT, ">testgraph.png") or die( "Cannot display image: $!" );