GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Variable::Disposition(3) User Contributed Perl Documentation Variable::Disposition(3)

Variable::Disposition - helper functions for disposing of variables

version 0.004

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

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

Currently provides "dispose" as a default import. To avoid this:

 use Variable::Disposition ();

In addition, "retain" and "retain_future" are available as optional imports.

 use Variable::Disposition qw(dispose retain retain_future);

The " :all " tag can be used to import every available function:

 use Variable::Disposition qw(:all);

but it would be safer to use a version instead:

 use Variable::Disposition qw(:v1);

since these are guaranteed not to change in future.

Other functions for use with Future and IO::Async are likely to be added later.

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.

Note that this clears the caller's variable.

This function is defined with a prototype of ($), since it is only intended for use on scalar variables. To clear multiple variables, use a foreach loop:

 my ($x, $y, $z) = ...;
 dispose $_ for $x, $y, $z;
 is($x, undef);
 is($y, undef);
 is($z, undef);

Keeps a copy of this variable until program exit or "dispose".

Returns the original variable.

Holds a copy of the given Future until it's marked ready, then releases our copy. Does not use "dispose", since that could interfere with other callbacks attached to the Future.

Returns the original Future.

  • 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.

Tom Molesworth <cpan@perlsite.co.uk>

Copyright Tom Molesworth 2014-2015. Licensed under the same terms as Perl itself.
2015-02-11 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.