Hi Monks,
I am writing a CGI application which basically creates a graph and displays it to the screen. My subroutine to do this (sub plot_graph) does this fine. However, I want the graph to be written to a different file each time the CGI is run - i have tried to do this by inserting
$$ in the graph filename but it stops working as soon as I do this. Can anyone suggest why this is happening and/or give some other suggestions.
Cheers
plot_graph ();
sub plot_graph {
my ($temps, $numbers) = @_;
# my @graph_data = (\@temps, \@numbers);
my @graph_data = (
["31768","25498", "21736", "17138", "9614", "6688",
+ "5016", "4180", "-2508", "-3762", "-5434", "-10450", "-12122", "-171
+38", "-20482", "-20900"],
[84.44, 68.55, 56.43, 39.71, 26.57, 15.05, 7.11, 1.93, -9.61, -17.56,
+-22.15, -34.69, -40.96, -48.91, -63.95, -71.04]
);
my $graph = GD::Graph::lines ->new (600,600);
$graph->set(
x_label => 'Temp',
y_label => 'Fluor',
x_max_value =>100
) or die $graph->error;
$graph->set (dclrs=> [qw(green red blue)]);
my $gb = $graph->plot(\@graph_data) or die $graph-
+>error;
open (IMG , '>out.png') or die $!;
binmode IMG;
print IMG $gb->png;
close IMG;
print qq(<img src=out.png>);
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.