in reply to Re: 'use strict' Rejecting Local Hash
in thread 'use strict' Rejecting Local Hash

    local %hash;    # no error, if %hash previously declared with my Actually, if %hash has previously been declared with my, that will generate an error: Can't localize lexical variable %hash ... Lexical variables cannot be localized. local() doesn't have a lexical effect, so it wouldn't really make sense if they could.

Replies are listed 'Best First'.
Re (tilly) 3: 'use strict' Rejecting Local Hash
by tilly (Archbishop) on Dec 28, 2000 at 09:08 UTC
    Actually lexical variables can be localized.
    use strict; my %hash = qw(hello world); print "$hash{hello}\n"; { local $hash{hello} = "WORLD"; print "$hash{hello}\n"; } print "$hash{hello}\n";
    There is no technical reason why this isn't doable for the original hash as well. The only reason why it cannot currently be done is that it is considered a likely cause of confusion.