in reply to Re^3: Capture not working
in thread Capture not working

I don't quite understand the last paragraph. Are you asking why the EOF test was buggy? No matter how many undef you add to $statement, it will never become false once it's true, so the die won't be executed.