|Perl Monk, Perl Meditation|
Re^2: Perl stops reading __DATA__ when meeting SUB character on Windows (history)by tye (Sage)
|on Jan 06, 2014 at 00:53 UTC||Need Help??|
I've been using Perl on Windows, and ^Z has never interrupted reading, even without binmode.
Perl on MS Windows has a long history of stopping reading at CTRL-Z (yes, even in files). That it predates your history with Perl on MS Windows (or just your memory) doesn't cause that history to no longer exist.
Your program produces 4 for me, whether binmode is commented out or not (v5.12).
I recall MS Windows changing its (default) treatment of CTRL-Z in files. This thread makes it clear that Perl did as well.
Some experiments lead me to believe that Perl has/had separate logic for stopping at CTRL-Z when reading Perl source code (and that binmode doesn't/didn't disable/reset that). I'll leave it to others to find that in the Perl source code and determine when that got removed as well (probably after v5.12 but before ikegami's version, which he doesn't mention).
At least, the DATA that Perl v5.12 opened for me stops at CTRL-Z whether binmode has been called on it or not (even after I control for the buffering problem I had experienced before and described elsewhere in this thread) while a DATA that I open myself reads CTRL-Z just fine, whether binmode is used or not.