in reply to Tool to record subroutine calls & return values

A quick search on CPAN brought me to Devel::CallTrace, which ties into the Perl debugger mechanism, but doesn't provide arguments and return values (although the code seems short enough that I guess it could probably be extended). Then there's Debug::Trace, which works by simply wrapping the requested subs with code that prints their arguments and return values:

$ cat foo.pl #!/usr/bin/env perl use warnings; use strict; sub foo { bar($_[0] x 3)."-".quz(ord($_[0])) } sub bar { $_[0].length($_[0]) } sub quz { $_[0].$_[0] } print foo($_), "\n" for 'a'..'b'; $ perl -MDebug::Trace=foo,bar,quz foo.pl TRACE: main::foo("a") called at foo.pl line 11 package main TRACE: main::bar("aaa") called at foo.pl line 5 sub main::foo TRACE: main::bar() returned: "aaa3" TRACE: main::quz(97) called at foo.pl line 5 sub main::foo TRACE: main::quz() returned: 9797 TRACE: main::foo() returned: ("aaa3-9797") aaa3-9797 TRACE: main::foo("b") called at foo.pl line 11 package main TRACE: main::bar("bbb") called at foo.pl line 5 sub main::foo TRACE: main::bar() returned: "bbb3" TRACE: main::quz(98) called at foo.pl line 5 sub main::foo TRACE: main::quz() returned: 9898 TRACE: main::foo() returned: ("bbb3-9898") bbb3-9898

At the bottom of the Devel::CallTrace doc, there are a few more references to other modules.

Update: Minor updates to wording.