frustrated in installing modules

frustrated in installing modules

am 03.04.2008 17:04:39 von ela

I use a function from GD::Graph::chart

and then it prompts me that no such module exists. Fine, using cpan to
install that, it says no such a module. back one level, install GD::Graph.
Ok, it's installed but still error persists. force install helps little.
Similar errors occur quite often and I'm really frustrated about this. Could
anybody tell me what's going wrong?

Re: frustrated in installing modules

am 03.04.2008 17:27:31 von smallpond

On Apr 3, 11:04 am, "Ela" wrote:
> I use a function from GD::Graph::chart
>
> and then it prompts me that no such module exists. Fine, using cpan to
> install that, it says no such a module. back one level, install GD::Graph.
> Ok, it's installed but still error persists. force install helps little.
> Similar errors occur quite often and I'm really frustrated about this. Could
> anybody tell me what's going wrong?

I suggest you re-read the documentation:

GD::Graph::chart->new([width,height])

"chart is either bars, lines, points, linespoints, area, mixed or
pie."


It would be nice if when you post, you give some code and the actual
error that you are getting instead of your interpretation. Makes
it a lot easier to help you.

Re: frustrated in installing modules

am 03.04.2008 17:31:38 von ela

Problem solved... Very, very sorry for causing inconvenience... sorry

New errors of export image format

am 03.04.2008 17:39:17 von ela

"smallpond" wrote in message
news:d25ee5eb-bbaf-4b26-926a-ebf6dcbf28ae@8g2000hse.googlegr oups.com...
> It would be nice if when you post, you give some code and the actual
> error that you are getting instead of your interpretation. Makes
> it a lot easier to help you.

The codes are as follows and now the problem becomes "Can't call method
"png" on an undefined value at plot_ss_b.pl line 34." printing error message
or not does not lead to great difference... The input file is like this:
==========
9 ~ 20.03
10 E 14.56
11 E 12.16
==========

#!/usr/bin/perl

use GD::Graph;
use GD::Graph::bars;

$filename = $ARGV[0];

open(FP, $filename);

while ($line = ) {
@words = split(/ /, $line);
if ($words[1] =~ /[A-Z]/) {
push @x, $words[0];
push @y, $words[2];
}
}

@data = (@x, @y);

close FP;

print $data[0], $data[1];

my $graph = GD::Graph::bars->new(400, 300) or die GD::Graph->error;

$graph->set(
title => 'B vs SS',
) or die $graph->error;

#open(IMG, ">$filename.gif") or die $!;
open(IMG, ">$filename.png") or die $!;
binmode IMG;
#$gd = $graph->plot(\@data)->gif;
$graph->plot(\@data)->png or die $graph->error;
print IMG $gd;
close IMG;

Re: New errors of export image format

am 03.04.2008 19:22:03 von glex_no-spam

Ela wrote:

> The codes are as follows and now the problem becomes "Can't call method
> "png" on an undefined value at plot_ss_b.pl line 34." printing error message
> or not does not lead to great difference... The input file is like this:

> ==========
> 9 ~ 20.03
> 10 E 14.56
> 11 E 12.16
> ==========
>
> #!/usr/bin/perl
>
> use GD::Graph;
> use GD::Graph::bars;
Missing:

use strict;
use warnings;

>
> $filename = $ARGV[0];
my $filename = $ARGV[0];
>
> open(FP, $filename);
And if it fails???..
open( my $fp, '<', $filename ) or die "Can't open $filename: $!";
>
> while ($line = ) {
while ( my $line = ) {
chomp( $line ); # or could chomp $words[2] in if()

> @words = split(/ /, $line);
> if ($words[1] =~ /[A-Z]/) {
> push @x, $words[0];
> push @y, $words[2];
> }
> }
>
> @data = (@x, @y);

This is not the correct data structure. Fix this
and it should work... provided you have the PNG
libraries.


>
> close FP;
close( $fp );
>
> print $data[0], $data[1];
This should print ARRAY(...) if @data is correct. Easiest to use
Data::Dumper to print the values;

use Data::Dumper;
print Dumper( @data );

>
> my $graph = GD::Graph::bars->new(400, 300) or die GD::Graph->error;

What formats can you use?

print 'Supported formats: ', join( ',', $graph->export_format ), "\n";

die "Need PNG libs" unless $graph->can( 'png' );
>
> $graph->set(
> title => 'B vs SS',
> ) or die $graph->error;
>
> #open(IMG, ">$filename.gif") or die $!;
> open(IMG, ">$filename.png") or die $!;
> binmode IMG;
> #$gd = $graph->plot(\@data)->gif;
> $graph->plot(\@data)->png or die $graph->error;
> print IMG $gd;

print IMG $graph->plot(\@data)->png;

or

$graph->plot( \@data );
print IMG $graph->png;

> close IMG;

Start with the examples in the documentation. If they work,
then you know it's something in your code.

Re: New errors of export image format

am 03.04.2008 20:23:42 von 1usa

"J. Gleixner" wrote in
news:47f5123c$0$48216$815e3792@news.qwest.net:

> Ela wrote:
>
>> $filename = $ARGV[0];
> my $filename = $ARGV[0];

I prefer

my ($filename) = @ARGV;

Then, adding another command line parameter results in only having
to change the LHS of the statement:

my ($filename, $device) = @ARGV;

Of course, one can only get so much out of positional parameters but
works for quick and dirty scripts.

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

Re: frustrated in installing modules

am 03.04.2008 20:25:31 von 1usa

"Ela" wrote in
news:ft2t8u$tee$1@ijustice.itsc.cuhk.edu.hk:

> Problem solved... Very, very sorry for causing inconvenience...
> sorry

No need to be so sorry to have asked for help. However, next time, you
can improve your chances of being able to help yourself by reading and
following the suggestions in the clpm guidelines. They are posted here
regularly (also, see my sig).

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

Re: New errors of export image format

am 04.04.2008 04:08:44 von ela

Thanks smallpond, J. Gleixner and A. Sinan Unur.

With your support I am near to finish. Now the only puzzling thing is that
contradictory results occur:

Supported formats: gif,png,gd,gd2
Need PNG libs at plot_ss_b.pl line 42.

with the following code excerpt, how come it says it support png but at the
same time dies? If I comment the die line, ok, it plots normally but without
anything generated. Finally, why I give this post "frustrated" is that Perl
FAQ, google, or codes message itself give few hints on getting relevant
dependencies. If I have to install whatever PNG, GIF libraries and so, I
don't mind. But the problem is that I don't know whether it is that problem,
and where to locate the libraries directly and correctly.

#@data = ([@x], [@y]);
@data = ([2,3,4], [1,1,1]);
#@data = (@x, @y);
close FP;

print 'Supported formats: ', join( ',', $graph->export_format ), "\n";
die "Need PNG libs" unless $graph->can( 'png' );

$graph->plot(\@data)->png or die $graph->error;
close IMG;

Re: New errors of export image format

am 04.04.2008 18:05:31 von glex_no-spam

Ela wrote:
> Thanks smallpond, J. Gleixner and A. Sinan Unur.
>
> With your support I am near to finish. Now the only puzzling thing is that
> contradictory results occur:
>
> Supported formats: gif,png,gd,gd2
> Need PNG libs at plot_ss_b.pl line 42.
>
> with the following code excerpt, how come it says it support png but at the
> same time dies? If I comment the die line, ok, it plots normally but without
> anything generated. Finally, why I give this post "frustrated" is that Perl
> FAQ, google, or codes message itself give few hints on getting relevant
> dependencies. If I have to install whatever PNG, GIF libraries and so, I
> don't mind. But the problem is that I don't know whether it is that problem,
> and where to locate the libraries directly and correctly.
>
> #@data = ([@x], [@y]);
> @data = ([2,3,4], [1,1,1]);
> #@data = (@x, @y);
> close FP;
>
> print 'Supported formats: ', join( ',', $graph->export_format ), "\n";
> die "Need PNG libs" unless $graph->can( 'png' );

That was just there as a different way to test for an
available format.

Hmm.. maybe I got that wrong.. After consulting the
documentation, which you can do via

perldoc GD::Graph

that should probably be:

die "Need PNG libs" unless $graph->gd->can( 'png' );

or

my $gd = $graph->plot(\@data) or die $graph->error;
die "Need PNG libs" unless $gd->can( 'png' );


>
> $graph->plot(\@data)->png or die $graph->error;

You need to write that output to your file.

> close IMG;

There are many examples in the distribution, take
a look at those too. From the perldoc:

"EXAMPLES
See the samples directory in the distribution, and read
the Makefile there. "