ackage Test::Utils::Dump; use Term::ANSIColor qw(colored); use Test::More; use strict; use Data::Dumper qw(Dumper); # export the dump function use Exporter qw(import); our @EXPORT_OK = qw(d); $Data::Dumper::Indent = 2; $Data::Dumper::Terse = 1; # dump the data passed in sub d { my $data = shift; my $out = ''; # print the data and the caller $caller_line = "Dump from: " . (caller(0))[1] . ' line: ' . (caller(0))[2]; diag colored(['yellow'], $caller_line); diag colored(['blue'], Dumper($data)); diag colored(['yellow'], $caller_line); }