From 0bf192cd0511eee455a4f883c78234613d0b8407 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 3 May 2013 13:15:16 +0200 Subject: [PATCH] Data::Dumper immer via 'use' und nicht 'require' einbinden MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ist schließlich ein Core-Modul. --- SL/LXDebug.pm | 24 ++++-------------------- SL/Template/Plugin/L.pm | 2 +- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index 17009ddcf..057ec06a1 100644 --- a/SL/LXDebug.pm +++ b/SL/LXDebug.pm @@ -16,26 +16,19 @@ use constant DEVEL => INFO | DEBUG1 | QUERY | TRACE | BACKTRACE_ON_ use constant FILE_TARGET => 0; use constant STDERR_TARGET => 1; +use Data::Dumper; use POSIX qw(strftime getppid); use Time::HiRes qw(gettimeofday tv_interval); use YAML; use strict; -my ($data_dumper_available, $text_diff_available); +my ($text_diff_available); -our $global_level; -our $watch_form; +our $global_level = NONE(); +our $watch_form = 0; our $file_name; -BEGIN { - eval("use Data::Dumper"); - $data_dumper_available = $@ ? 0 : 1; - - $global_level = NONE; - $watch_form = 0; -} - sub new { my $type = shift; my $self = {}; @@ -159,7 +152,6 @@ sub warn { sub dump { my ($self, $level, $name, $variable, %options) = @_; - if ($data_dumper_available) { my $password; if ($variable && ('Form' eq ref $variable) && defined $variable->{password}) { $password = $variable->{password}; @@ -183,14 +175,6 @@ sub dump { } return $output; - - } else { - $self->message($level, - "dumping ${name}: Data::Dumper not available; " - . "variable cannot be dumped"); - - return undef; - } } sub dump_yaml { diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index fa1869215..95f4ce1d0 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -2,6 +2,7 @@ package SL::Template::Plugin::L; use base qw( Template::Plugin ); use Template::Plugin; +use Data::Dumper; use List::MoreUtils qw(apply); use List::Util qw(max); use Scalar::Util qw(blessed); @@ -439,7 +440,6 @@ sub online_help_tag { sub dump { my $self = shift; - require Data::Dumper; return '
' . Data::Dumper::Dumper(@_) . '
'; } -- 2.20.1