From d6c4fcd1fc185f8e6dfb3c3f67d500195fc42e2a Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sun, 21 Jan 2024 22:04:59 +0000 Subject: [PATCH 1/2] Ensure that core boolean support doesn't fail on perls older than 5.36 --- lib/Data/Printer/Filter/SCALAR.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Data/Printer/Filter/SCALAR.pm b/lib/Data/Printer/Filter/SCALAR.pm index 419d427..544685c 100644 --- a/lib/Data/Printer/Filter/SCALAR.pm +++ b/lib/Data/Printer/Filter/SCALAR.pm @@ -4,7 +4,7 @@ use warnings; use Data::Printer::Filter; use Scalar::Util; -my $HAS_BOOLEAN = $] ge '5.036000' && eval 'use builtin; 1'; +use constant HAS_BOOLEAN => $] ge '5.036000' && eval 'use builtin; 1'; filter 'SCALAR' => \&parse; filter 'LVALUE' => sub { @@ -25,7 +25,7 @@ sub parse { if (not defined $value) { $ret = $ddp->maybe_colorize('undef', 'undef'); } - elsif ($HAS_BOOLEAN && _is_bool($value)) { + elsif (HAS_BOOLEAN && _is_bool($value)) { if ($value) { $ret = $ddp->maybe_colorize('true', 'true'); } else { @@ -132,7 +132,7 @@ sub _is_number { } sub _is_bool { - no warnings 'experimental::builtin'; + no if HAS_BOOLEAN, warnings => 'experimental::builtin'; return builtin::is_bool($_[0]); } From e85d188d4c53feb684f5278500677eec0d8d76a2 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sun, 21 Jan 2024 22:07:47 +0000 Subject: [PATCH 2/2] No need to check for builtin.pm; the functions are always accessible --- lib/Data/Printer/Filter/SCALAR.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Data/Printer/Filter/SCALAR.pm b/lib/Data/Printer/Filter/SCALAR.pm index 544685c..81ccfb7 100644 --- a/lib/Data/Printer/Filter/SCALAR.pm +++ b/lib/Data/Printer/Filter/SCALAR.pm @@ -4,7 +4,7 @@ use warnings; use Data::Printer::Filter; use Scalar::Util; -use constant HAS_BOOLEAN => $] ge '5.036000' && eval 'use builtin; 1'; +use constant HAS_BOOLEAN => $] ge '5.036000'; filter 'SCALAR' => \&parse; filter 'LVALUE' => sub {