Most people don't realize that a localized copy of a variable does not retain its original value.
Unless you initialize the variable when you local-ize it,
it defaults to undef.
If you want the variable to retain its original value,
just initialize it to itself.
If you really do want the localized copy to be undef,
then make it explicit.