Next Tricks of the Wizards 40

Wrappers

        package Trace;
        sub import {
          my $caller = caller;
          my @functions = @_ ? @_ : all_functions($caller);
          for my $func_name (@functions) {
            my $real_func = \&*$func_name;
            *{$caller . "::$func_name"} = sub {
              print "$func_name(@_)\n";
              $real_func->(@_);
            };
          }
        }        


Next Copyright © 2003 M. J. Dominus