Resource::Dispose - Syntax sugar for dispose pattern
use Resource::Dispose; { resource my $obj = Some::Class->new; } # $obj->DISPOSE is called even if $obj can not be freed and destroyed
The dispose pattern is a design pattern which is used to handle resource cleanup in runtime environment that use automatic garbage collection. In Perl there is possibility that the object will be destructed during global destruction and it leads to memory leaking and other drawbacks like unclosed file handles, etc.
This module provides new keyword resource as a syntax sugar for dispose pattern. The DISPOSE method of the resource object is called if the resource is going out of scope.
resource
DISPOSE
This resource keyword is inspired by using keyword from C# language and extended try keyword from Java 7 language.
using
try
Guard, Scope::Guard, Devel::Declare.
If you find the bug or want to implement new features, please report it at https://github.com/dex4er/perl-Resource-Dispose/issues
The code repository is available at http://github.com/dex4er/perl-Resource-Dispose
Piotr Roszatycki <dexter@cpan.org>
Copyright (c) 2012 Piotr Roszatycki <dexter@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as perl itself.
See http://dev.perl.org/licenses/artistic.html
To install Resource::Dispose, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Resource::Dispose
CPAN shell
perl -MCPAN -e shell install Resource::Dispose
For more information on module installation, please visit the detailed CPAN module installation guide.