But dangerous as a pattern. Once you hit undef on ARGV (also
known as the empty file handle or the diamond operator), you should stop
reading from it, or you will end up reading from STDIN instead.
So your post works fine for all filehandles that stay at EOF once you hit EOF.
The magic ARGV filehandle does not.