From 66d132cd4bff58f0595dc0db31dd4c5bdc0407c1 Mon Sep 17 00:00:00 2001 From: Christian Loos Date: Mon, 23 Nov 2015 08:14:28 +0100 Subject: [PATCH] always load Data::Dumper Data::Dumper is in core sice Perl 5.005, so set a minimum Perl dependency and always load Data::Dumper. --- mysqltuner.pl | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index e6278f4..cb4c33c 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -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 ); @@ -2792,30 +2798,19 @@ 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')) { 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)