@dates = `mysqlshow --password=\'xxxxxxx\' pzbg001`;
shift @dates;
shift @dates;
shift @dates;
shift @dates;
pop @dates;
foreach $date(@dates){
chomp $date;
$date =~ s/ //g;
$date =~ s/\|//g;
$date =~ s/\-//g;
$date =~ s/Tables//g;
$date =~ s/\+//g;
...
####
@dates = map { /^\|\s+([\d_]+)\s+\|$/ } `mysqlshow --...`
####
$query = "select $result from $date where inintf=$inint";
####
# get the list of tables (table names are \d+_\d+_\d+):
my @dates = map { /^\|\s+([\d_]+)\s+\|$/ } `mysqlshow --...`
# query each table for sum of traffic,
# push table_name (i.e. date) and traffic sum onto @data:
my @data = ();
for my $date ( @dates ) {
my $query = "select $result from $date where inintf=$inint";
my $sth = $dbh->prepare($query);
if (!$sth) { die "Illegal query: $query" };
$sth->execute;
my $octets = ($sth->fetchrow_array)[0]; # don't chomp it!
$sth->finish;
push @data, [ $date, $octets/(1024*1024) ];
}
# do all that other GD stuff... then:
my $myimage = $mygraph->plot(\@data) or die $mygraph->error;
# and on to the web page...