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


In reply to Re: Problem in make function and draw chart by kcott
in thread Problem in make function and draw chart by GHMON

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.