From dbb5bfee033ceb2600d5017d370b9533f6e6d6f7 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Tue, 19 Apr 2022 00:37:14 -0600 Subject: [PATCH] Add a couple fixes for older perls --- lib/File/KDBX.pm | 1 - lib/File/KDBX/Error.pm | 7 ++++++- lib/File/KDBX/IO.pm | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/File/KDBX.pm b/lib/File/KDBX.pm index 2dcf341..3f52d6c 100644 --- a/lib/File/KDBX.pm +++ b/lib/File/KDBX.pm @@ -15,7 +15,6 @@ use Ref::Util qw(is_ref is_arrayref is_plain_hashref); use Scalar::Util qw(blessed refaddr); use Time::Piece; use boolean; -use warnings::register; use namespace::clean; our $VERSION = '999.999'; # VERSION diff --git a/lib/File/KDBX/Error.pm b/lib/File/KDBX/Error.pm index 6ea0649..fbc6bbd 100644 --- a/lib/File/KDBX/Error.pm +++ b/lib/File/KDBX/Error.pm @@ -15,7 +15,12 @@ our @EXPORT = qw(alert error throw); my $WARNINGS_CATEGORY; BEGIN { $WARNINGS_CATEGORY = 'File::KDBX'; - warnings::register_categories($WARNINGS_CATEGORY) if warnings->can('register_categories'); + if (warnings->can('register_categories')) { + warnings::register_categories($WARNINGS_CATEGORY); + } + else { + eval qq{package $WARNINGS_CATEGORY; use warnings::register; 1}; ## no critic ProhibitStringyEval + } } use overload '""' => 'to_string', cmp => '_cmp'; diff --git a/lib/File/KDBX/IO.pm b/lib/File/KDBX/IO.pm index 0ea5d9c..5d18347 100644 --- a/lib/File/KDBX/IO.pm +++ b/lib/File/KDBX/IO.pm @@ -366,7 +366,7 @@ if ($ENV{DEBUG_IO}) { my $indented_method = (' ' x $debug{level}) . $method; my $self = shift; print STDERR sprintf('%-20s -> %s (%s)', $indented_method, $self, - join(', ', map { defined ? substr($_, 0, 16) : 'undef' } @_)), "\n"; + join(', ', map { defined $_ ? substr($_, 0, 16) : 'undef' } @_)), "\n"; my $r = $orig->($self, @_) // 'undef'; print STDERR sprintf('%-20s <- %s [%s]', $indented_method, $self, $r), "\n"; return $r; -- 2.45.2