Merge pull request #137 from cloos/dependencies
Dependencies Thanks @cloos This solution is nicer than the way I try to do it :)
This commit is contained in:
commit
8935266d06
1 changed files with 30 additions and 45 deletions
|
@ -36,14 +36,20 @@
|
||||||
# http://forge.mysql.com/projects/view.php?id=44
|
# http://forge.mysql.com/projects/view.php?id=44
|
||||||
#
|
#
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
|
use 5.005;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use diagnostics;
|
use diagnostics;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use Cwd 'abs_path';
|
use Cwd 'abs_path';
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
$Data::Dumper::Pair = " : ";
|
||||||
|
|
||||||
# Set up a few variables for use in the script
|
# Set up a few variables for use in the script
|
||||||
my $tunerversion = "1.6.1";
|
my $tunerversion = "1.6.1";
|
||||||
my ( @adjvars, @generalrec );
|
my ( @adjvars, @generalrec );
|
||||||
|
@ -639,19 +645,6 @@ sub mysql_setup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub try_load {
|
|
||||||
my $mod = shift;
|
|
||||||
|
|
||||||
eval("use $mod");
|
|
||||||
|
|
||||||
if ($@) {
|
|
||||||
#print "\$@ = $@\n";
|
|
||||||
return(0);
|
|
||||||
} else {
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# MySQL Request Array
|
# MySQL Request Array
|
||||||
sub select_array {
|
sub select_array {
|
||||||
my $req = shift;
|
my $req = shift;
|
||||||
|
@ -2792,34 +2785,26 @@ END_TEMPLATE
|
||||||
}
|
}
|
||||||
sub dump_result {
|
sub dump_result {
|
||||||
if ($opt{'debug'}) {
|
if ($opt{'debug'}) {
|
||||||
|
|
||||||
if (try_load('Data::Dumper')) {
|
|
||||||
badprint "Data::Dumper Module is needed.";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
use Data::Dumper qw/Dumper/;
|
|
||||||
$Data::Dumper::Pair = " : ";
|
|
||||||
debugprint Dumper( \%result );
|
debugprint Dumper( \%result );
|
||||||
}
|
}
|
||||||
|
|
||||||
debugprint "HTML REPORT: $opt{'reportfile'}";
|
debugprint "HTML REPORT: $opt{'reportfile'}";
|
||||||
|
|
||||||
if ($opt{'reportfile'} ne 0 ) {
|
if ($opt{'reportfile'} ne 0 ) {
|
||||||
if (try_load('Text::Template')) {
|
eval "{ use Text::Template }";
|
||||||
|
if ($@) {
|
||||||
badprint "Text::Template Module is needed.";
|
badprint "Text::Template Module is needed.";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
if (try_load('Data::Dumper')) {
|
|
||||||
badprint "Data::Dumper Module is needed.";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
use Text::Template;
|
|
||||||
use Data::Dumper qw/Dumper/;
|
|
||||||
$Data::Dumper::Pair = " : ";
|
|
||||||
my $vars= {'data' => Dumper( \%result ) };
|
my $vars= {'data' => Dumper( \%result ) };
|
||||||
|
|
||||||
my $template = Text::Template->new(TYPE => 'STRING', PREPEND => q{;}, SOURCE => $templateModel)
|
my $template;
|
||||||
or die "Couldn't construct template: $Text::Template::ERROR";
|
{
|
||||||
|
no warnings 'once';
|
||||||
|
$template = Text::Template->new(TYPE => 'STRING', PREPEND => q{;}, SOURCE => $templateModel)
|
||||||
|
or die "Couldn't construct template: $Text::Template::ERROR";
|
||||||
|
}
|
||||||
open my $fh, q(>), $opt{'reportfile'}
|
open my $fh, q(>), $opt{'reportfile'}
|
||||||
or die "Unable to open $opt{'reportfile'} in write mode. please check permissions for this file or directory";
|
or die "Unable to open $opt{'reportfile'} in write mode. please check permissions for this file or directory";
|
||||||
$template->fill_in(HASH =>$vars, OUTPUT=>$fh );
|
$template->fill_in(HASH =>$vars, OUTPUT=>$fh );
|
||||||
|
|
Loading…
Reference in a new issue