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
|
||||
#
|
||||
package main;
|
||||
|
||||
use 5.005;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use diagnostics;
|
||||
use File::Spec;
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
use Data::Dumper;
|
||||
$Data::Dumper::Pair = " : ";
|
||||
|
||||
# Set up a few variables for use in the script
|
||||
my $tunerversion = "1.6.1";
|
||||
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
|
||||
sub select_array {
|
||||
my $req = shift;
|
||||
|
@ -2792,34 +2785,26 @@ END_TEMPLATE
|
|||
}
|
||||
sub dump_result {
|
||||
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 "HTML REPORT: $opt{'reportfile'}";
|
||||
|
||||
if ($opt{'reportfile'} ne 0 ) {
|
||||
if (try_load('Text::Template')) {
|
||||
eval "{ use Text::Template }";
|
||||
if ($@) {
|
||||
badprint "Text::Template Module is needed.";
|
||||
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 $template = Text::Template->new(TYPE => 'STRING', PREPEND => q{;}, SOURCE => $templateModel)
|
||||
my $template;
|
||||
{
|
||||
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'}
|
||||
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 );
|
||||
|
|
Loading…
Reference in a new issue