]> git.vpit.fr Git - perl/modules/Variable-Temp.git/blob - README
Generate t/20-lvalue.t from t/10-base.t
[perl/modules/Variable-Temp.git] / README
1 NAME
2     Variable::Temp - Temporarily change the value of a variable.
3
4 VERSION
5     Version 0.01
6
7 SYNOPSIS
8         use Variable::Temp 'temp';
9
10         my $x = 1;
11         say $x; # 1
12         {
13          temp $x = 2;
14          say $x; # 2
15         }
16         say $x; # 1
17
18 DESCRIPTION
19     This module provides an utility routine that can be used to temporarily
20     change the value of a variable, until the end of the current scope is
21     reached where the original value of the variable is restored. It is
22     similar to "local", except that it can be applied onto lexicals as well
23     as globals, and that it replaces values by copying the new value into
24     the container variable instead of by aliasing.
25
26 FUNCTIONS
27   "temp"
28         temp $var;
29         temp $var = $value;
30
31     Temporarily replace the value of the lexical or global variable $var by
32     $value, or by "undef" if $value is omitted, until the end of the current
33     scope. Any subsequent assignments to $var in the current (or any
34     inferior) scope will not affect the original value which will be
35     restored into the variable at scope end. Several "temp" calls can be
36     made onto the same variable, and the restore are processed in reverse
37     order.
38
39     Note that destructors associated with $var will not be called when
40     "temp" sets the temporary value, but only at the natural end of life of
41     the variable (i.e. at the end of the scope). They will trigger after any
42     destructor associated with the replacement $var.
43
44 EXPORT
45     The function "temp" is only exported on request by passing 'temp' to the
46     module import list.
47
48 CAVEATS
49     Currently only applies to scalar variables.
50
51 DEPENDENCIES
52     perl 5.6.
53
54     Scope::Upper.
55
56     Exporter (core since perl 5).
57
58 SEE ALSO
59     Scope::Upper.
60
61     "local" in perlfunc.
62
63 AUTHOR
64     Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
65
66     You can contact me by mail or on "irc.perl.org" (vincent).
67
68 BUGS
69     Please report any bugs or feature requests to "bug-variable-temp at
70     rt.cpan.org", or through the web interface at
71     <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Variable-Temp>. I will
72     be notified, and then you'll automatically be notified of progress on
73     your bug as I make changes.
74
75 SUPPORT
76     You can find documentation for this module with the perldoc command.
77
78         perldoc Variable::Temp
79
80 COPYRIGHT & LICENSE
81     Copyright 2015 Vincent Pit, all rights reserved.
82
83     This program is free software; you can redistribute it and/or modify it
84     under the same terms as Perl itself.
85