Value::Canary - Callbacks for value destruction
version 0.01
use Value::Canary; my $i = 0; { my $value = 42; canary $value, sub { $i++ }; ... # $i is still 0 } # end of scope causes $value to be destroyed and the callback to be invoked # $i is now 1
This module provides an easy way to get notified as soon as a value is being destroyed. This is mostly handy for debugging purposes, when you want to find out which code is throwing the value you passed in away, instead of using it for something useful.
Registers a $callback to be called as soon as $variable is being destroyed. The callback will be invoked with a reverence to the $variable as its only argument. If no callback is given, a default callback will be used. The default callback will warn with a full stack trace of where the value is being destroyed, as well as the message "$value destroyed".
$callback
$variable
"$value destroyed"
This function is exported by default. See Sub::Exporter on how to customize how exactly exporting happens.
Variable::Magic
Scope::Guard
Object::Deadly
Florian Ragwitz <rafl@debian.org>
This software is copyright (c) 2009 by Florian Ragwitz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Value::Canary, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Value::Canary
CPAN shell
perl -MCPAN -e shell install Value::Canary
For more information on module installation, please visit the detailed CPAN module installation guide.