Gossamer Forum
Home : Products : DBMan : Customization :

Extracting data to another cgi script

Quote Reply
Extracting data to another cgi script
Hi! I'm stumped. I have sucessfully select some fields from my database to be copied onto another field named stats.db But I need to know how do I pass those data to another script. Basically the script is using the Data:Xtab module that would take some data and plot out some graph.

I did have it working for plotting out a graph for website logging stats. the following code was what I did:

use lib ("/home/sites/site126/users/vampiro/web/lib/blib/lib");
use Data::Xtab;
use strict;
use GIFgraph::lines;
use CGI;
my $query = new CGI;

my @data = &parse_log('web.log');

my @outputcols = (0..23);
my $xtab = new Data::Xtab(\@data, \@outputcols);

my @graph_data = $xtab->graph_data;
pop @graph_data;
my @legend= ('@data');
my $proxygraph = new GIFgraph::lines(500,400);

$proxygraph->set( 'x_label' => 'Hour of Day',
'y_label' => 'Kb Requested',
'title' => 'Total Load by Hour',
'y_max_value' => 1,
'y_min_value' => 0,
'y_tick_number' => 5,
'y_label_skip' => 2
);

$proxygraph->set_legend(@legend);
print $query->header(-type => "image/gif");
print $proxygraph->plot( \@graph_data );

sub parse_log {

my $filename = shift @_;
my @returnvalue;
my ($host, $hour, $bytes);

open (INFILE, "$filename") || die "Couldn't open $filename!";

while (<INFILE>) {

$_ = /^(.+?)\s.+?:(..):.+?\s(\d+?).+?\s$/;

($host, $hour, $bytes) = ($1, $2+0, $3/1000);

if($host && $hour && $bytes) {
push @returnvalue, [ $host, $hour, $bytes ];
}
}
return @returnvalue;
}

1;

Basically I think the crux of the program lies with the line in red. This would take the weblog file and search through it and fish out the data by the pattern matching which is also defined in the red line. The question now is how do I fish the data out from my stats.db file which is something like this:

Gregory Griffiths|Excellent|Good|Julian Ng|Very Good

I want each of those 5 fields to be fished out.

I would really appreciate any help I can get.

Julian