While we could use simple print statements instead of these functions, using these functions will ensure that our diagnostic messages won't
interfere with any future changes in TAP, the Test Anything Protocol. So it is worth using them
instead of print.

diag

diag() accepts a list of values, and will print it to the Standard Error stream of the test script preceded by a # sign to indicate
to the TAP processor harness that this is just a comment. Not part of the protocol.

note

When running the test script directly note() does the same as diag(), printing the parameters to STDERR.
The difference occurs when we run the script under harness using prove. In that case messages printed using diag()
will still show up, while messages printed by note() will be hidden.

This is a simple test script with a diag(), a note(), and a single ok() call.

use strict;
use warnings;
use Test::More tests => 1;
diag "This is from diag";
note "This if from note";
ok 1;

perl test.pl results in this output, where both diag and note messages can be seen:

1..1
# This is from diag
# This if from note
ok 1

Running via the harness using prove test.pl will generated this output, where
only the diag message will show up.

explain

explain comes in handy when we need to print out complex data structures. It is like a smart version
a href="https://metacpan.org/pod/Data::Dumper">Data::Dumper. If we give it a simple scalar it will return
the same scalar and if we give it a reference to a data structure, we get a nicely formatted version of that data
structure. Of course we still need to print it using either diag(), or note(), but it is nice
and compact.

This sample script has 3 variables. First we call diag() passing each one of the variables. This produces
readable output only if the variable had scalar content such as a string or a number. Then we call diag()
3 times passing what explain() returned.