Skip to content

Commit

Permalink
Add mcall
Browse files Browse the repository at this point in the history
  • Loading branch information
gisle committed Jan 2, 2009
1 parent d504f83 commit cbc6908
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/Data/Dump/Trace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Data::Dump::Trace;
use strict;

use base 'Exporter';
our @EXPORT_OK = qw(call wrap);
our @EXPORT_OK = qw(call mcall wrap);

use Data::Dump qw(dump);
use Term::ANSIColor qw(YELLOW CYAN RESET);
Expand Down Expand Up @@ -52,4 +52,25 @@ sub call {
}
}

sub mcall {
my $o = shift;
my $method = shift;
my $oname = ref($o) ? "\$o" : $o;
print YELLOW, $oname, "->", $method, dumpav(@_), RESET;
if (!defined wantarray) {
print "\n";
$o->$method(@_);
}
elsif (wantarray) {
my @s = $o->$method(@_);
print " ==> ", CYAN, dumpav(@s), RESET, "\n";
return @s;
}
else {
my $s = $o->$method(@_);
print " ==> ", CYAN, dump($s), RESET, "\n";
return $s;
}
}

1;

0 comments on commit cbc6908

Please sign in to comment.