From: Charles McGarvey Date: Tue, 19 Apr 2022 06:37:14 +0000 (-0600) Subject: Add a couple fixes for older perls X-Git-Tag: v0.800~26 X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=dbb5bfee033ceb2600d5017d370b9533f6e6d6f7;p=chaz%2Fp5-File-KDBX Add a couple fixes for older perls --- 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;