File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -722,7 +722,9 @@ you would call on some variety of IO::Socket object.
722
722
723
723
= item local EXPR
724
724
725
- The Perl 6 equivalent is C < temp > .
725
+ The Perl 6 equivalent is C < temp > . Unlike C < local > , however, the value of
726
+ the given variable is not immediately unset: it retains its original value
727
+ until assigned to.
726
728
727
729
= head2 localtime
728
730
Original file line number Diff line number Diff line change @@ -1172,17 +1172,25 @@ details.
1172
1172
sub prefix:<temp>(Mu $a is rw)
1173
1173
= end code
1174
1174
1175
- "temporizes" the variable passed as the argument, which means it is reset
1176
- to its old value on scope exit. For example:
1175
+ "temporizes" the variable passed as the argument. The variable begins
1176
+ with the same value as it had in the outer scope, but can be assigned
1177
+ new values in this scope. Upon exiting the scope, the variable will be
1178
+ restored to its original value.
1177
1179
1178
1180
my $a = "three";
1179
1181
say $a; # three
1180
1182
{
1181
- temp $a = "four";
1183
+ temp $a;
1184
+ say $a; # three
1185
+ $a = "four";
1182
1186
say $a; # four
1183
1187
}
1184
1188
say $a; # three
1185
1189
1190
+ Note that you can also assign immediately as part of the call to temp:
1191
+
1192
+ temp $a = "five";
1193
+
1186
1194
= head2 prefix C « let »
1187
1195
1188
1196
= begin code :skip-test
You can’t perform that action at this time.
0 commit comments