in reply to Re: Changing ENV values locally
in thread Changing ENV values locally

Your code example is an excellent demonstration of exactly what the local keyword does. Except you don't have to pick a name like save_term for the old version of the value.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^3: Changing ENV values locally
by BrowserUk (Patriarch) on Jul 02, 2005 at 20:25 UTC

    I know you know this, but it's worth mentioning another big advantage of local over the hand-coded equivalents exampled by your respondee.

    The programmer (or another at some later time) may modify the code such that it returns without restoring the original value.

    With local, this won't happen. The programmer might forget, but the compiler/interpreter will not.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.