in reply to Re: Save/restore STDIN
in thread Save/restore STDIN

I agree with count zero's suggestion.

local uses run time scoping, it saves the current content of your variable onto the run-time stack, and then automatically restores it when the thread of executions leaves the scope.