Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Char::Plot problems

by house15 (Initiate)
on Dec 31, 2003 at 19:34 UTC ( #317978=perlquestion: print w/replies, xml ) Need Help??
house15 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, Everyone. I'm trying to get Chart::Plot to work. I don't get any errors that I can find. The data seems to be set right and appropriate bounds on the graph. I send the results string to an output file like:
open (OUT, "> plot.png"); print OUT $img->draw(); close OUT;
and everything seems to work fine, but when I try to view the results image, the viewer tells me it's not png or that it is corrupted. I opened up the png data in vim and it says PNG at the top so I'm guessing it's corrupted. Also, I used  $img->image_type() and the result is png, so my version of GD (2.11) should be supporting it. Any ideas? Thanks, House.

Replies are listed 'Best First'.
Re: Char::Plot problems
by MidLifeXis (Monsignor) on Dec 31, 2003 at 20:32 UTC

    A couple things...

    • Check the results of your open call.
    • Check the results of your print - I am guessing that draw() is bailing, and may return something
    • Make sure to use strict; use warnings;

    Good luck


      Thanks for your response. I've been using strict and  warnings . The open and the print are working, too as far as I can tell. Supposedly, if  draw() fails an error is set in the  Chart::Plot object, which I check for.

      In short, the script ends with no errors and the draw() function writes to the file. It just doesn't seem to be writing the right stuff.

      Obviously, I'm baffled.
Re: Char::Plot problems
by PERLscienceman (Curate) on Dec 31, 2003 at 22:40 UTC
    open (OUT, "> plot.png"); binmode OUT; print OUT $img->draw(); close OUT;
      You, sir, are a genius. I saw that in the examples, but the comment said it was for "DOSish" systems. Since I'm a newbie and on LINUX I ignored that. Thanks for the help. House.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://317978]
Approved by sgifford
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-02-20 20:04 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.