#!/usr/bin/perl -w BEGIN { use CGI::Carp qw(carpout); open(\*MYLOG, '>>', "VMwith-db.log") or die("Unable to open perl.log: $!\n"); carpout(MYLOG); } use PDF::API2; use PDF::Table; use perlchartdir; use DBI; use MIME::Lite; use strict; use warnings; use diagnostics; use CGI qw(:standard); use constant mm => 25.4/72; use constant in => 1/72; use constant pt => 1; my %valueHash; my %User_Preferences; my $q = new CGI; print $q->header( "text/plain" ); open( CONFIG, 'variables.conf' ); while () { chomp; # no newline s/#.*//; # no comments s/^\s+//; # no leading white s/\s+$//; # no trailing white next unless length; # anything left? my ($var, $value) = split(/\s*=\s*/, $_, 2); $User_Preferences{$var} = $value; } close (CONFIG); my $dbhost = $User_Preferences{"localhost"}; my $dsn = "dbi:mysql:$User_Preferences{\"dbName\"}:$dbhost"; my $db_user_name = $User_Preferences{"db_user_name"}; my $db_password = $User_Preferences{"db_password"}; my $dbh = DBI->connect($dsn, $db_user_name, $db_password); my $selectState = qq{SELECT uid, fparams FROM vmware WHERE flag = 10}; my $sth = $dbh->prepare($selectState); $sth->execute or die "Can't execute SQL statement: $DBI::errstr\n"; ## search through the database - so we can run the pdf for every row while ((my $key, my $row) = $sth->fetchrow_array()) { my $workingFlag = qq{UPDATE vmware SET flag = 20 WHERE uid = $key}; $dbh->do($workingFlag) or die "Can't Update DataBase: $DBI::errstr\n"; my $fparams = join('', $row); %valueHash = map split(/=/, $_, 2), split /\|\|/, $fparams; #while( my($key2, $value2) = each(%valueHash)){ # print " KEY: $key2..... VALUE: $value2 \n "; #} #do PDF Stuff HERE .... }#WHILE LOOP THROUGH THE db warn"Data fetching terminated early by error: $DBI::errstr\n" if $DBI::err;