perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

Make Data::Dumper boolean aware.

Open EvanCarroll opened this issue 1 year ago • 3 comments

Perl now has a literal syntax for

  • !!1 which makes to builtin::true
  • !!0 which maps to builtin::false

But when you use Dumper you see,

perl -MData::Dumper -E'say Data::Dumper::Dumper( { true => !!1, false => !!0 } );'
$VAR1 = {
          'false' => '',
          'true' => 1
        };

And you don't even see that these values pass builtin::is_bool. I think a better display would be.

perl -MData::Dumper -E'say Data::Dumper::Dumper( { true => !!1, false => !!0 } );'
$VAR1 = {
          'false' => *builtin::false,
          'true' => *builtin::true,
        };

But even the !!1 and !!0 would be great.

EvanCarroll avatar Jun 17 '24 14:06 EvanCarroll

$ perl -MData::Dumper -E'say Data::Dumper::Dumper( { true => !!1, false => !!0 } );'
$VAR1 = {
          'false' => !!0,
          'true' => !!1
        };

$ perl -v

This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux-thread-multi-ld
...

This was implemented in Data::Dumper 2.187, which is not on CPAN, so you need perl 5.38 or newer.

mauke avatar Jun 17 '24 16:06 mauke

@mauke why isn't it on cpan?

EvanCarroll avatar Jun 17 '24 17:06 EvanCarroll

Because nobody has done the work to release it yet.

This will only be relevant for 5.36, but it would be nice to do.

haarg avatar Jun 17 '24 21:06 haarg