http://www.perlmonks.org?node_id=1044361


in reply to extract the function call chains of specific length

Assuming that you start with a data structure like this:
{ main => [qw(f1 f2 f3 f4 f5)], f1 => [qw(f2)], f2 => [qw(f3,f4)], ... }
then I'd use that to create a bunch of perl subroutines that contain the right subroutine calls and which use Devel::StackTrace (or caller() to figure out how they were called and log that. Then just call main().