So when the foreach loop finishes it restores the undef value to $_. Thanks.
In reply to Re^4: What is the scope of $_? by Lotus1 in thread What is the scope of $_? by Anonymous Monk