package Module; use Attribute::Handlers; sub TRACE :ATTR(CODE,BEGIN) { my ($pkg, $sym, $ref, $attr, $data, $phase, $file, $line) = @_; *{ $sym } = sub { warn "$file($line) called with [@_]\n"; my( @rc )= &$ref; warn "$file($line): returning [ @rc ]\n"; } } sub new :TRACE{ my $instance = shift; my $class = ref($instance) || $instance; my $self = {}; return bless($self, $class); } 1; #### #!/usr/local/bin/perl my $module_to_load = 'Module'; eval "use $module_to_load;"; # Create object my $obj = Module->new(); print "CLASS: " . ref($obj) ."\n";