The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Variable::Disposition - helper functions for disposing of variables

VERSION

Version 0.001

SYNOPSIS

 use feature qw(say);
 use Variable::Disposition;
 my $x = [];
 dispose $x;
 say '$x is no longer defined';

DESCRIPTION

Provides some basic helper functions for making sure variables go away when you want them to.

Currently only includes "dispose", and exports this by default. Other functions for use with Future and IO::Async are likely to be added later.

METHODS

dispose

Undefines the given variable, then checks that the original ref was destroyed.

 my $x = [1,2,3];
 dispose $x;
 # $x is no longer defined.

This is primarily intended for cases where you no longer need a variable, and want to ensure that you haven't accidentally captured a strong reference to it elsewhere.

SEE ALSO

  • Devel::Refcount - assert_oneref is almost identical to this, although it doesn't clear the variable it's called on

  • Closure::Explicit - provides a sub{} wrapper that will complain if you capture a lexical without explicitly declaring that you're going to do that.

INHERITED METHODS

Exporter

as_heavy, export, export_fail, export_ok_tags, export_tags, export_to_level, import, require_version

AUTHOR

Tom Molesworth <cpan@perlsite.co.uk>

LICENSE

Copyright Tom Molesworth 2014. Licensed under the same terms as Perl itself.