Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI::Application::GDGraph issue 1

Status
Not open for further replies.

CristianLuca

Programmer
Oct 25, 2007
36
RO
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::Data;

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::Data->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
 
The "line 44" refers to some code being evaluated, so it is possibly in one of the templates. Your best approach to solving this is with a debugger. If you have an X server or a TK installation, I'd recommend Devel::ptkdb and start your script with [tt]perl -d:ptkdb myscript[/tt]. If you cannot get ptkdb running, you always have the standard debugger: start your script with [tt]perl -d myscript[/tt].

Run through once, stepping over each function call until you find the one which blows. Start again, run to the failing function call and step into it. Once inside, step over each function call until you find the culprit. You can repeat this procedure until you locate the line that is failing.

A shortcut is to use the call-stack back-trace facility but, if you are new to debugging perl, this is probably a little too much for starters.

Give it a go: the deugging environment is rich and powerful and easily repays the moderate effort required to learn it.

Yours,

fish

[&quot;]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life was going to be spent in finding mistakes in my own programs.[&quot;]
--Maurice Wilkes, 1949
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top