NAME
    Variable::Temp - Temporarily change the value of a variable.

VERSION
    Version 0.01

SYNOPSIS
        use Variable::Temp 'temp';

        my $x = 1;
        say $x; # 1
        {
         temp $x = 2;
         say $x; # 2
        }
        say $x; # 1

DESCRIPTION
    This module provides an utility routine that can be used to temporarily
    change the value of a variable, until the end of the current scope is
    reached where the original value of the variable is restored. It is
    similar to "local", except that it can be applied onto lexicals as well
    as globals, and that it replaces values by copying the new value into
    the container variable instead of by aliasing.

FUNCTIONS
  "temp"
        temp $var;
        temp $var = $value;

    Temporarily replace the value of the lexical or global variable $var by
    $value, or by "undef" if $value is omitted, until the end of the current
    scope. Any subsequent assignments to $var in the current (or any
    inferior) scope will not affect the original value which will be
    restored into the variable at scope end. Several "temp" calls can be
    made onto the same variable, and the restore are processed in reverse
    order.

    Note that destructors associated with $var will not be called when
    "temp" sets the temporary value, but only at the natural end of life of
    the variable (i.e. at the end of the scope). They will trigger after any
    destructor associated with the replacement $var.

EXPORT
    The function "temp" is only exported on request by passing 'temp' to the
    module import list.

CAVEATS
    Currently only applies to scalar variables.

DEPENDENCIES
    perl 5.6.

    Scope::Upper.

    Exporter (core since perl 5).

SEE ALSO
    Scope::Upper.

    "local" in perlfunc.

AUTHOR
    Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.

    You can contact me by mail or on "irc.perl.org" (vincent).

BUGS
    Please report any bugs or feature requests to "bug-variable-temp at
    rt.cpan.org", or through the web interface at
    <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Variable-Temp>. I will
    be notified, and then you'll automatically be notified of progress on
    your bug as I make changes.

SUPPORT
    You can find documentation for this module with the perldoc command.

        perldoc Variable::Temp

COPYRIGHT & LICENSE
    Copyright 2015 Vincent Pit, all rights reserved.

    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

