use Test::Utils::Dump; use Test::Dirs; # sets up temporary scratch directories use Test; use_ok('File'); my $f = File->new(); $f->path($Test::Dirs::scratch . 'test.txt'); d $f; # d sub is in Test::Utils::Dump #### 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; }