Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I copied the code from Chart::Pie sample in CPAN.org. But how do I applied it in HTML?.

I tried writing print $chart at the end of the code, hoping that it will print out the pie. But when I go to that page, This appear "Not a GLOB reference at /home/www/us...." And the file pie.gif is created in my server directory. When I open pie.gif it is the pie I wanted. So I know it work but my implementation is wrong. But I wish the pie to appear on that page not that error.

So I need help on how do I display this file without that error? TQ

Replies are listed 'Best First'.
Re: teach me Chart::Pie
by kutsu (Priest) on Feb 18, 2005 at 16:18 UTC

    "Teach Me" is a phrase I've found myself hearing quite often, and one I've come to loath. "Teach Me", I have found, usually means "I want to learn something with little effort on my part". Students who come with this attitude often become weights attach to the backs of other students, forcing you to spend extra time teaching and re-teaching a lesson when other students are ready to progress - then finding that the "Teach Me" student has moved on finding it still to much effort and sometimes a good student has been lost because of his lack of progress, lack of steady improvement.

    This is less to say anything about the AM who posted this, being as I've never meet him, and more to do with the annoyance and wasted time such a phrase has cost me (both as teacher and student). I suggest that a better phrase, better attitude perhaps, would be "Help me to Learn".

    As for the actually question: How about a snippet or some example code, showing the error?

    "Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

      Sorry for your time or anyone else. The code is the same as on CPAN.org. I just copied it, that why I didn't understand how it work. It seem the code create a .gif file. I do think they should tell how to use the code, as I can't understand the code by just looking at it.
      use Chart::Pie; my $chart = Chart::Pie->new(640,480); $chart->set( 'title' => 'A Day in the Life', 'x_label' => 'X Axis Label', 'y_label' => 'Y Axis Label' , 'label_values' => 'percent', # tell me percentage of # each day spent on # each activity 'x_ticks' => 'none', 'y_ticks' => 'none', ); $chart->add_dataset( qw(Junk_X_Tick_Label) ); $chart->add_dataset( qw(8) ); $chart->add_dataset( qw(8) ); $chart->add_dataset( qw(2) ); $chart->add_dataset( qw(6) ); $chart->set('legend_labels' => [ 'Sleep', 'Work', 'Eat', 'Watch TV' + ]); $chart->gif('pie.gif');
        $chart->gif('pie.gif');
        If you RTFM of the module you are using, and the modules it uses, you'll see that this code makes a file. Nothing in there (nor in the module developer's head!) says that this module will be used to generate a web page. Your webserver is loading file 'index.html' (or whatever). If you had told the webserver to load 'pie.gif', it would have done so and you would have gotten what you expected.

        Let me say that I ++ you because you kept on trying after asking your question here. Perl by itself is a BIG subject and tossing in UN!X, Apache, and the Web as well makes it truly complex, and we all get bitten by the multiple levels of interaction once in a while. (At least, I know I do!). You will be much rewarded as a coder if you take the time and patience to think through what's happening when you don't get what you expect. :D

        In this script, $chart is a Chart::Pie object and not the pie chart you want to display. The pie chart is output as pie.gif. In order to display the gif you will need to learn how to write CGI scripts. Ovid has a nice online CGI Course and there is a wealth of information on the subject here at PerlMonks.

Re: teach me Chart::Pie
by g0n (Priest) on Feb 18, 2005 at 16:03 UTC
    Can you post the code please, or at least the portion where the error occurs. Without that, its going to be very difficult to identify the problem.

    Update:Reworded this for clarity a couple of times

    VGhpcyBtZXNzYWdlIGludGVudGlvbmFsbHkgcG9pbnRsZXNz
      Thanks for trying to help. I solve it. I just need to put <img src="pie.gif">. I just did trial and error. I don't know why and never expect it to work that way.