NAME Class::Method::Debug - Trace who is calling accessors VERSION version 1.101420 SYNOPSIS use Class::Method::Debug ':tracer'; enable_scalar_tracer(name => 'foo'); enable_hash_tracer('header', mykey => 'myvalue'); DESCRIPTION Provides method modifiers that trace who is setting scalar and hash attributes. FUNCTIONS enable_scalar_tracer Takes as a mandatory argument an accessor name and enables a tracer on that accessor that prints a stack trace every time a value is set using the accessor. The accessor is expected to be for a scalar attribute. If you pass an optional second argument, the stack trace will only be printed if the value being set is (string) equal to that argument. This function is exported either by direct request or via the ":tracer" tag. Examples: use Class::Method::Debug ':tracer'; enable_scalar_tracer('last_name'); enable_scalar_tracer('first_name', 'Hikaru'); The first tracer is run every time a new value is set using the "last_name()" accessor. The second tracer is run every time the "first_name()" accessor is used to set the attribute to "Hikaru". So: $obj->last_name('Shindou'); # triggers stack trace $obj->last_name; # no stack trace $obj->first_name('Hikaru'); # triggers stack trace $obj->first_name('Akira'); # no stack trace $obj->first_name; # no stack trace enable_hash_tracer Takes as a mandatory argument an accessor name and enables a tracer on that accessor that prints a stack trace every time a value is set using the accessor. The accessor is expected to be for a hash attribute. If you pass an optional second argument, the stack trace will only be printed if that hash key is being set. If you pass an optional third argument, the stack trace will only be printed if the value being set on that hash key is (string) equal to that argument. This function is exported either by direct request or via the ":tracer" tag. Examples: use Class::Method::Debug ':tracer'; enable_hash_tracer('config'); enable_hash_tracer('address', 'zip'); enable_hash_tracer('header', 'to', 'foo@bar.com'); The first tracer is run every time any hash value is set using the "config()" accessor. The second tracer is run every time the "aaddress()" accessor is used to set the "zip" key. The third tracer is run every time the "header()" accessor is used to set the "to" key to "foo@bar.com". So: $obj->config(foo => 'bar'); # triggers stack trace $obj->config; # no stack trace $obj->address(zip => 1080); # triggers stack trace $obj->address(country => 'AT'); # no stack trace $obj->address; # no stack trace $obj->header(to => 'foo@bar.com'); # triggers stack trace $obj->header(to => 'baz@flurble.com'); # no stack trace $obj->header(from => 'foo@bar.com'); # no stack trace $obj->header; # no stack trace print_stacktrace Makes the stack trace, beautifies it, drops the frame from the tracer itself and warns it. INSTALLATION See perlmodinstall for information and options on installing Perl modules. BUGS AND LIMITATIONS No bugs have been reported. Please report any bugs or feature requests through the web interface at . AVAILABILITY The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit to find a CPAN site near you, or see . The development version lives at . Instead of sending patches, please fork this project using the standard git and github infrastructure. AUTHOR Marcel Gruenauer COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Marcel Gruenauer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.