in reply to Re^4: use 'local' modifier to hashref element
in thread use 'local' modifier to hashref element
... complains that you "Can't localize lexical variable @array", but it has no problem localizing $hash{foo}.
It has no problem localizing the value of an array element, either:
my %hash; my @array; { local $hash{foo} = 'bar'; local $array[1] = 'foo'; print "inner scope:\n"; print "$_ => $hash{$_}\n" for keys %hash; print "[$_] $array[$_]\n" for 0..$#array; } print "outer scope:\n"; print "$_ => $hash{$_}\n" for keys %hash; print "[$_] $array[$_]\n" for 0..$#array; __END__ inner scope: foo => bar [0] [1] foo outer scope:
Were you trying to localize the entire hash - as you did with @array - perl would complain also:
Can't localize lexical variable %hash at foo line x.
|
---|