Glad you found the problem. Consider using Tie::File as a practical alternative if you're doing in-place editing. (In some cases it may not be appropriate -- read the docs -- but for many cases, it is.)
Comment on Re^5: Make select apply to modules as well