3 # $RCSfile: local.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:04 $
12 { local($a,$c) = ("ok 9\n", "ok 10\n"); ($x, $y) = ($a, $c); }
22 print &foo("ok 1\n","ok 2\n");
24 print $a,$b,$c,$d,$x,$y;
26 # same thing, only with arrays and associative arrays
33 { local($a,@c) = ("ok 19\n", "ok 20\n"); ($x, $y) = ($a, @c); }
43 print &foo2("ok 11\n","ok 12\n");
45 print $a,@b,@c,%d,$x,$y;
48 print +($@ =~ /Can't localize through a reference/) ? "" : "not ", "ok 21\n";
51 print +($@ =~ /Can't localize through a reference/) ? "" : "not ", "ok 22\n";
54 print +($@ =~ /Can't localize through a reference/) ? "" : "not ", "ok 23\n";
56 # Array and hash elements
62 print +($a[1] eq 'foo') ? "" : "not ", "ok 24\n";
63 print +($a[2] eq 'c') ? "" : "not ", "ok 25\n";
66 print +($a[1] eq 'b') ? "" : "not ", "ok 26\n";
67 print +($a[2] eq 'c') ? "" : "not ", "ok 27\n";
68 print +(!defined $a[0]) ? "" : "not ", "ok 28\n";
75 print +($a[0].$a[1] eq "Xb") ? "" : "not ", "ok 29\n";
77 %h = ('a' => 1, 'b' => 2, 'c' => 3);
79 local($h{'a'}) = 'foo';
80 local($h{'b'}) = $h{'b'};
81 print +($h{'a'} eq 'foo') ? "" : "not ", "ok 30\n";
82 print +($h{'b'} == 2) ? "" : "not ", "ok 31\n";
86 print +($h{'a'} == 1) ? "" : "not ", "ok 32\n";
87 print +($h{'b'} == 2) ? "" : "not ", "ok 33\n";
88 print +($h{'c'} == 3) ? "" : "not ", "ok 34\n";
90 # check for scope leakage
92 if (1) { local $a = 'inner' }
93 print +($a eq 'outer') ? "" : "not ", "ok 35\n";
95 # see if localization works when scope unwinds
103 print $m == 5 ? "" : "not ", "ok 36\n";