# This is the custom debugger: { package DB; sub DB {} sub sub { print STDERR "== Entering sub $sub\n"; &$sub; # Call the sub print STDERR "=== Leaving sub $sub\n"; } } # Now some example code to test it with: sub hello { print "Hello, "; world(); } sub world { print "World!\n"; } $|++; # Turn off buffering, to make the control flow clearer hello();