eval 'local(%$e)';
print +($@ =~ /Can't localize through a reference/) ? "" : "not ", "ok 23\n";
-# check for scope leakage
-
-$a = 'outer';
-if (1) { local $a = 'inner' }
-print +($a eq 'outer') ? "" : "not ", "ok 24\n";
-
-# see if localization works when scope unwinds
-
-local $m = 5;
-eval {
- for $m (6) {
- local $m = 7;
- die "bye";
- }
-};
-print $m == 5 ? "" : "not ", "ok 25\n";
-
# Array and hash elements
@a = ('a', 'b', 'c');
{
local($a[1]) = 'foo';
local($a[2]) = $a[2];
- print +($a[1] eq 'foo') ? "" : "not ", "ok 26\n";
- print +($a[2] eq 'c') ? "" : "not ", "ok 27\n";
+ print +($a[1] eq 'foo') ? "" : "not ", "ok 24\n";
+ print +($a[2] eq 'c') ? "" : "not ", "ok 25\n";
undef @a;
}
-print +($a[1] eq 'b') ? "" : "not ", "ok 28\n";
-print +($a[2] eq 'c') ? "" : "not ", "ok 29\n";
-print +(!defined $a[0]) ? "" : "not ", "ok 30\n";
+print +($a[1] eq 'b') ? "" : "not ", "ok 26\n";
+print +($a[2] eq 'c') ? "" : "not ", "ok 27\n";
+print +(!defined $a[0]) ? "" : "not ", "ok 28\n";
@a = ('a', 'b', 'c');
{
local($a[1]) = "X";
shift @a;
}
-print +($a[0].$a[1] eq "Xb") ? "" : "not ", "ok 31\n";
+print +($a[0].$a[1] eq "Xb") ? "" : "not ", "ok 29\n";
%h = ('a' => 1, 'b' => 2, 'c' => 3);
{
local($h{'a'}) = 'foo';
local($h{'b'}) = $h{'b'};
- print +($h{'a'} eq 'foo') ? "" : "not ", "ok 32\n";
- print +($h{'b'} == 2) ? "" : "not ", "ok 33\n";
+ print +($h{'a'} eq 'foo') ? "" : "not ", "ok 30\n";
+ print +($h{'b'} == 2) ? "" : "not ", "ok 31\n";
local($h{'c'});
delete $h{'c'};
}
-print +($h{'a'} == 1) ? "" : "not ", "ok 34\n";
-print +($h{'b'} == 2) ? "" : "not ", "ok 35\n";
-print +($h{'c'} == 3) ? "" : "not ", "ok 36\n";
+print +($h{'a'} == 1) ? "" : "not ", "ok 32\n";
+print +($h{'b'} == 2) ? "" : "not ", "ok 33\n";
+print +($h{'c'} == 3) ? "" : "not ", "ok 34\n";
+
+# check for scope leakage
+$a = 'outer';
+if (1) { local $a = 'inner' }
+print +($a eq 'outer') ? "" : "not ", "ok 35\n";
+
+# see if localization works when scope unwinds
+local $m = 5;
+eval {
+ for $m (6) {
+ local $m = 7;
+ die "bye";
+ }
+};
+print $m == 5 ? "" : "not ", "ok 36\n";