package Test::Utils::Dump; use Term::ANSIColor qw(colored); use strict; use warnings; use Data::Dumper qw(Dumper); # export the dump function use Exporter qw(import); our @EXPORT_OK = qw(d); # dump the data passed in sub d { my $data = shift; print colored ['green'], "\nDumping data...\n"; # print the data and the caller my $caller_line = "Dump from: " . (caller(0))[1] . ' line: ' . (caller(0))[2] . "\n"; print colored(['green'], "\n" . $caller_line); print Dumper($data); print $caller_line; }