X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=lib%2FVariable%2FTemp.pm;h=be72888ace01d7b421b3e291464b175232961c1a;hb=44bbd934b677f763001b163b1b96c58d6d6b8602;hp=8d307cd18d476e9145a1d46c097af8150d807b34;hpb=325778545db343888e4f002fd170c4eb557fdaa5;p=perl%2Fmodules%2FVariable-Temp.git
diff --git a/lib/Variable/Temp.pm b/lib/Variable/Temp.pm
index 8d307cd..be72888 100644
--- a/lib/Variable/Temp.pm
+++ b/lib/Variable/Temp.pm
@@ -53,7 +53,10 @@ Any subsequent assignments to C<$var> in the current (or any inferior) scope wil
Several C calls can be made onto the same variable, and the restore are processed in reverse order.
Note that destructors associated with C<$var> will B be called when C 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 C<$var>.
+They will trigger after any destructor associated with the replacement C<$value>.
+
+Due to a shortcoming in the handling of the C<\$> prototype, which was addressed in C 5.14, the pseudo-statement C will cause compilation errors on C 5.12.x and below.
+If you want your code to run on these versions of C, you are encouraged to use L instead.
=cut
@@ -64,9 +67,26 @@ sub temp (\$) :lvalue {
$$var;
}
+=head2 C
+
+ set_temp $var;
+ set_temp $var => $value;
+
+A non-lvalue variant of L that can be used with any version of C.
+
+=cut
+
+sub set_temp (\$;$) {
+ my $var = $_[0];
+ my $save = $$var;
+ &Scope::Upper::reap(sub { $$var = $save } => Scope::Upper::UP);
+ $$var = $_[1] if @_ >= 2;
+ return;
+}
+
=head1 EXPORT
-The function L is only exported on request by passing C<'temp'> to the module import list.
+The functions L and L are only exported on request by specifying their names in the module import list.
=cut
@@ -74,7 +94,7 @@ use base 'Exporter';
our @EXPORT = ();
our %EXPORT_TAGS = ();
-our @EXPORT_OK = 'temp';
+our @EXPORT_OK = qw;
=head1 CAVEATS