in reply to Problem in make function and draw chart
G'day GHMON,
I added this to the top of your posted code (and saved as 'pm_1227027_orig.pl'):
#!/usr/bin/env perl
I also needed to install GD::Graph:
$ cpan ... cpan[1]> install GD::Graph ... RUZ/GDGraph-1.54.tar.gz /usr/bin/make install -- OK cpan[2]> q
I checked the syntax:
$ perl -c pm_1227027_orig.pl pm_1227027_orig.pl syntax OK
Running the program showed that "Second Number" was requested twice: you should look into that. Here's an example run:
$ pm_1227027_orig.pl First Number > 1 Second Number > 2 MEAN = 1.517 Variance = 1515.415 Second Number > 2 0.0102507203875771 2 0.0205014407751541
Checking for the output:
$ ls -al FirstPracticeTest.jpeg -rw-r--r-- 1 ken staff 63191 Dec 10 21:20 FirstPracticeTest.jpeg
And a quick check on what that file actually is:
$ file FirstPracticeTest.jpeg FirstPracticeTest.jpeg: JPEG image data, JFIF standard 1.01, aspect ra +tio, density 1x1, segment length 16, comment: "CREATOR: gd-jpeg v1.0 +(using IJG JPEG v80), default quality", baseline, precision 8, 2000x2 +000, frames 3
"... but i couldn't show a chart that create by my code ..."
I don't really know what that means. Obviously, the file is there, it contains data, it has read permissions for all, and is recognised as JPEG. If you had difficulty opening FirstPracticeTest.jpeg in some image viewer, let us know which one; also try others to see if the problem persists. If there any messages — for example, indicating corrupt data — you should post those as well.
You could also check for the version of GD::Graph you have installed. Perhaps an older versions had bugs. Consider upgrading if you don't have the latest.
There's a few other things that would improve your code:
I don't believe any of that will change how your short, example script works. They are, however, all good habits to get into. If this script is extended, embedded within some other script, or used as the logic for a module, benefits will accrue: for example, code is less error-prone, easier to debug if errors do occur, and easier to maintain.
— Ken
|
|---|