Skip to content

Commit

Permalink
Merge pull request #190 from leonerd/backcompat-booleans
Browse files Browse the repository at this point in the history
Ensure that core boolean support doesn't fail on perls older than 5.36
  • Loading branch information
garu authored Jan 22, 2024
2 parents 7a76fd4 + e85d188 commit ee3acd0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Data/Printer/Filter/SCALAR.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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';

filter 'SCALAR' => \&parse;
filter 'LVALUE' => sub {
Expand All @@ -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 {
Expand Down Expand Up @@ -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]);
}

Expand Down

0 comments on commit ee3acd0

Please sign in to comment.