Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi,

While I also am not entirely clear on your problem, I have managed to get your modified code to work simply scoping @temp1 and $domain using my, and by not printing the header out to the same location as the data. The following code generates a PNG image on STDOUT:

#!/usr/bin/perl -w # Declare the stuff we need to use use strict; use CGI; use GD::Graph::linespoints; use constant TITLE => "AAA Days to Integration Average: Line Chart"; my $q = new CGI; my $graph = new GD::Graph::linespoints(600, 300); my $largestValue = 0; my (@xAxisOfDates,@yAxisOfPartners,@yAxisOfArf, @data) = (); #open(HANDLE,"integrate.dat"); # commented out 'cos I'm using DATA while (<DATA>) { # note DATA here chomp; my @temp1 = split(/\|/, $_); # use strict needs 'my' here my $domain = unpack ("A5", $temp1[17]); # and here push (@xAxisOfDates, $temp1[1]); push (@yAxisOfPartners, $temp1[4]); push (@yAxisOfArf, $temp1[5]); if ($temp1[4] > $largestValue){ $largestValue = $temp1[4]; } if ($temp1[5] > $largestValue){ $largestValue = $temp1[5]; } } #close(HANDLE); # using DATA for simplicity here @data = (\@xAxisOfDates, \@yAxisOfPartners, \@yAxisOfArf); $graph->set( title => TITLE, x_label => "Third Quarter FY 2002", y_label => "Average Days", long_ticks => 1, y_max_value => $largestValue, y_min_value => 0, y_tick_number => 10, y_label_skip => 0, bar_spacing => 4, types => [ "linespoints", "linespoints" ], dclrs => [ "red", "black" ], ); $graph->set( markers => [1,1] ); $graph->set_legend( "Partners", "ARF" ); my $gd_image = $graph->plot( \@data ); # I don't know where you want this, but putting it # in the png doesn't seem to work :-P #print $q->header( -type => "image/png", -expires => "-1d" ); binmode STDOUT; print $gd_image->png; #get_data(); # undefined function; perl not happy __DATA__ 1|1/27|2002|3|26|19|7|7|21|10|3|34|7|73|undef|71|6|20 2|2/03|2002|3|26|19|8|28|21|10|3|34|7|73|undef|72|6|20 3|2/10|2002|3|24|24|8|28|21|10|3|46|7|73|undef|72|8|20 4|2/17|2002|3|22|23|6|28|21|10|3|46|7|73|undef|72|8|20 5|2/24|2002|3|18|23|6|28|22|10|3|46|38|73|undef|72|8|20 6|3/03|2002|3|13|25|6|36|18|28|9|33|38|44|undef|65|8|20 7|3/10|2002|3|13|35|11|50|22|28|9|33|38|44|undef|65|8|20 8|3/18|2002|3|12|33|11|62|24|28|9|33|38|44|undef|65|undef|undef
Note that I had to turn taint checking off ("Too late for -T option..."). I'm afraid I don't have the time right now to address this issue and must therefore leave it as an exercise for the reader :-)
I hope this answers your problem.

Tim

Update: *sigh*, shows how often I use -T...
This thread explains the taint problem I was having. In short: don't worry about it :-P


In reply to Re: Re: Flat File Database & GD::Graph (REVISITED) by tfrayner
in thread Flat File Database & GD::Graph (REVISITED) by suggus

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (5)
    As of 2014-12-27 11:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (177 votes), past polls