> So far the script is working fine with the print in the main() which is a
> run_mode. It only the problem while showing the graph. I'm not sure if there
This is probably because your browser (internet explorer?) is assuming the
header of "text/html". Not all browsers do this, and you shouldn't rely
on it.
> from the database. The text part is still working fine with all the changes,
> its just the graph which dosn't showup.
It may be working, but it should be changed. It won't work in all
browsers, and you aren't following the CGI::App expectations, which means
the "working" behavior could disappear in a future upgrade (although I'll
grant it's unlikely in this case)
> package perfmonpvt;
...
> sub showsrvrs {
...
All of the below prints should be appended to a variable that is
returned to CGI::App. Likewise "exit 0" should probably be removed, since
that just bypasses CGI::App.
> if($dbh eq undef) ## Check to see if the connection to DB is OK.
> {
> print $q->blockquote("<h1>Connection to server failed. </h1>");
> print $q->blockquote("This could be due to an invalid Login
> Name,Password,Server Name.");
> print $q->blockquote("If you feel all of these are correct, then pls check
> of the server is running and your login is not locked.");
> print $q->blockquote("Still if you can't connect, Pls check you interfaces
> of sql.ini files.");
> exit 0;
> }
...
This section (below) is exactly how it should all be done, as far as
"print" is concerned.
> my $output = '';
> $output .= $q->start_html(-title => 'Sysmon Details');
> $output .= $q->blockquote($q->strong("<h1>Check Sysmon
> Details</h1>"));
> $output .= $q->start_form();
...
> sub showdetails {
...
The below section, however, completely bypasses CGI::App. It should be
altered to behave like the above block.
> print "Content-type:text/html \n\n";
> print $q->start_html(-title => 'Sysmon Details');
...
> showgraph(); ## New line to display the graph.
As previously mentioned, if you're appending all of the (current) print
statements into a variable, you'll want to append the return value of
showgraph() to that variable as well.
> die "Can't open the data file\n" unless open(DF,"<c:/temp/grph.txt");
Just as a helpful note, it's often very useful to print $! in die()s like
this, it gives you some clue WHY it couldn't open the file. something
like:
die "Can't open the data file: $!\n" unless open(DF,"<c:/temp/grph.txt");
Works just fine.
...
> return $graph->plot(\@data)->$format();
Here you return a value, which is then lost in the ether because the
calling routine doesn't use it.
Also, since the calling routine has the graph INSIDE an html page, I don't
think this will do what you want. Modifying the header is only useful if
that is what you are returning (i.e. if you wanted to show the graph only,
no html.) Since this is not the case, I think you'll have to either save
the graph to a file and reference it in the returned HTML, or make a
separate cgi that just returns an image and reference it (by reference I
mean in a IMG html tag). HTML doesn't allow you to embed the actual image
in the same page, it's a separate file.
Hope that helps to clear things up.
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]