Variable::OnDestruct - Call a subroutine on destruction of a variable.
Version 0.03
use Variable::OnDestruct; on_destruct $var, sub { do_something() }; on_destruct @array, sub { do_something_else() }; on_destruct %array, sub { hashes_work_too() }; on_destruct &$sub, sub { so_do_closures($but_not_normal_subs) }; on_destruct *$glob, sub { and_even_globs($similar_caveats_as_subs_though) };
This module allows you to let a function be called when a variable gets destroyed. The destructor will work not only on scalars but also on arrays, hashes, subs and globs. For the latter two you should realize that most of them aren't scoped like normal variables. Subs for example will only work like you expect them to when they are closures.
This module contains one function, which is exported by default.
This function adds a destructor to a variable.
Leon Timmermans, <leont at cpan.org>
<leont at cpan.org>
Please report any bugs or feature requests to bug-devel-ondestruct at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Variable-OnDestruct. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-devel-ondestruct at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Variable::OnDestruct
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Variable-OnDestruct
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Variable-OnDestruct
CPAN Ratings
http://cpanratings.perl.org/d/Variable-OnDestruct
Search CPAN
http://search.cpan.org/dist/Variable-OnDestruct
Copyright 2009,2010 Leon Timmermans, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Variable::OnDestruct, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Variable::OnDestruct
CPAN shell
perl -MCPAN -e shell install Variable::OnDestruct
For more information on module installation, please visit the detailed CPAN module installation guide.