in reply to Re^3: What is the scope of $_?in thread What is the scope of $_?
So when the foreach loop finishes it restores the undef value to $_. Thanks.