CristianLuca
Programmer
I'm trying to learn how does CGI::Application::GDGraph works, but there isn't to much free and fast documentation out there, many just cut and paste from the same source : CPAN, and examples are not self explanatory when it comes to relate them with other components that use them or get used by them, enyways i have this example :
#!/usr/bin/perl -w
use strict;
use CGI::Application::GDGraph::lines_ap;
use CGI::Session;
use CGI qw/standard/);
use GD::Graph:ata;
my $path_to_templates = '/home/cristil/perl_learning/graph_generation/CGI/';
my $html_template = 'template.tmpl';
my $session_file_directory = '/home/cristil/perl_learning/graph_generation/CGI/';
# NB: session_file_directory must be writable by user under which the web server runs
my $dat = &get_raw_data;
my @legend = qw(CPU Swap Load_Avg);
my $graph = CGI::Application::GDGraph::lines_ap->new(
TMPL_PATH => $path_to_templates,
PARAMS => {
'DAT' => $dat,
'legend' => \@legend,
'x_size' => 600,
'y_size' => 300,
'x_label' => 'X LABEL HERE',
'y_label' => 'Y LABEL HERE',
'page_title' => 'GRAPH TITLE HERE',
'tmpl' => $html_template,
'session_dir'=> $session_file_directory,
'fgclr' => '#222222',
'labelclr' => '#777777',
'legendclr' => '#666666',
'textclr' => '#666666',
}
);
$graph->x_label_ratio("25");
$graph->run();
sub get_raw_data {
my $CSV = '/home/cristil/perl_learning/graph_generation/CGI/csvfile.txt';
my $delim = ",";
my $dat = GD::Graph:ata->new();
$dat->read(file => $CSV, delimiter => $delim);
}
and i get the error :
Use of uninitialized value in substitution (s///) at (eval 18) line 44.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.8/CGI/Application/GDGraph/lines_ap.pm line 220.
Set-Cookie: CGISESSID=bd9351c428a230b127d93e61e54246e8; path=/; expires=Mon, 26-Nov-2007 15:41:59 GMT
Date: Mon, 26 Nov 2007 14:41:59 GMT
Content-Type: text/html; charset=ISO-8859-1
<head>
<title>GRAPH TITLE HERE</title>
</head>
<body bgcolor="black">
<div align="center">
<font color="white" face="courier">
<table border=0>
<tr>
<td align="center"><H1><font face="courier" color="white">GRAPH TITLE HERE</H1></td>
</tr>
<tr>
<td><img src = "/cgi-bin/?rm=graph_img"></td>
</tr>
</table>
<a href ="test_db_session.cgi">back</a>
</font>
</div>
</body>
</html>
</body>
BUT there is NO line 44 in my current script, and all the paths and filename are correct. What's the deal ? I'm just interested to make one single example work properly and then i can figure out afterwards. This library is a mess.
Thank you in advance,
Cristian
#!/usr/bin/perl -w
use strict;
use CGI::Application::GDGraph::lines_ap;
use CGI::Session;
use CGI qw/standard/);
use GD::Graph:ata;
my $path_to_templates = '/home/cristil/perl_learning/graph_generation/CGI/';
my $html_template = 'template.tmpl';
my $session_file_directory = '/home/cristil/perl_learning/graph_generation/CGI/';
# NB: session_file_directory must be writable by user under which the web server runs
my $dat = &get_raw_data;
my @legend = qw(CPU Swap Load_Avg);
my $graph = CGI::Application::GDGraph::lines_ap->new(
TMPL_PATH => $path_to_templates,
PARAMS => {
'DAT' => $dat,
'legend' => \@legend,
'x_size' => 600,
'y_size' => 300,
'x_label' => 'X LABEL HERE',
'y_label' => 'Y LABEL HERE',
'page_title' => 'GRAPH TITLE HERE',
'tmpl' => $html_template,
'session_dir'=> $session_file_directory,
'fgclr' => '#222222',
'labelclr' => '#777777',
'legendclr' => '#666666',
'textclr' => '#666666',
}
);
$graph->x_label_ratio("25");
$graph->run();
sub get_raw_data {
my $CSV = '/home/cristil/perl_learning/graph_generation/CGI/csvfile.txt';
my $delim = ",";
my $dat = GD::Graph:ata->new();
$dat->read(file => $CSV, delimiter => $delim);
}
and i get the error :
Use of uninitialized value in substitution (s///) at (eval 18) line 44.
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.8/CGI/Application/GDGraph/lines_ap.pm line 220.
Set-Cookie: CGISESSID=bd9351c428a230b127d93e61e54246e8; path=/; expires=Mon, 26-Nov-2007 15:41:59 GMT
Date: Mon, 26 Nov 2007 14:41:59 GMT
Content-Type: text/html; charset=ISO-8859-1
<head>
<title>GRAPH TITLE HERE</title>
</head>
<body bgcolor="black">
<div align="center">
<font color="white" face="courier">
<table border=0>
<tr>
<td align="center"><H1><font face="courier" color="white">GRAPH TITLE HERE</H1></td>
</tr>
<tr>
<td><img src = "/cgi-bin/?rm=graph_img"></td>
</tr>
</table>
<a href ="test_db_session.cgi">back</a>
</font>
</div>
</body>
</html>
</body>
BUT there is NO line 44 in my current script, and all the paths and filename are correct. What's the deal ? I'm just interested to make one single example work properly and then i can figure out afterwards. This library is a mess.
Thank you in advance,
Cristian