explain(); will recognize if its parameter is a simple scalar or a reference to a more complex data structure.

Its result must be passed to either note(); does or diag();

examples/perl/t/33_explain.t
use strict;
use warnings;

use lib 'lib';
use MyTools;

use Test::More tests => 2;


is(sum(1, 1),    2,     '1+1');
is(sum(2, 2),    4,     '2+2');

my $x = "String data";
my $y = [ 1, 2, 3 ];
my %h = (
    foo => 'bar',
    numbers => [ 42, 17 ],
);

diag $x;
diag $y;
diag \%h;

diag explain $x;
diag explain $y;
diag explain \%h;

$ perl t/33_explain.t

1..2
ok 1 - 1+1
ok 2 - 2+2
# String data
# ARRAY(0x7fc2aa804268)
# HASH(0x7fc2ab0651e8)
# String data
# [
#   1,
#   2,
#   3
# ]
# {
#   'foo' => 'bar',
#   'numbers' => [
#     42,
#     17
#   ]
# }