Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl stops reading __DATA__ when meeting SUB character on Windows

by ikegami (Pope)
on Jan 05, 2014 at 18:37 UTC ( #1069405=note: print w/ replies, xml ) Need Help??


in reply to Perl stops reading __DATA__ when meeting SUB character on Windows

That's very odd. I've been using Perl on Windows, and ^Z has never interrupted reading, even without binmode.

Without binmode, the following outputs 10 ("foo\n\cZ\nbar\n"), and 13 with ("foo\r\n\cZ\r\nbar\r\n").

#binmode(DATA); local $/; $x = <DATA>; print(length($x), "\n"); # 10, 13 with binmode __DATA__ foo <Character 1A here> bar

I use ActivePerl. How did you build your Perl? If binmode doesn't solve your problem, you have a broken perl. I'd be interested in seeing the output of perl -V. (That's an uppercase "V".)


Comment on Re: Perl stops reading __DATA__ when meeting SUB character on Windows
Select or Download Code
Re^2: Perl stops reading __DATA__ when meeting SUB character on Windows (history)
by tye (Cardinal) on Jan 06, 2014 at 00:53 UTC
    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.

    - tye        

      That it predates your history with Perl on MS Windows (or just your memory) doesn't cause thaat history to no longer exist.

      1. The OP is using binmode. That should never stop at ^Z!

      2. Unless you're saying the OP is using a Perl older than 5.6, I don't see your point. I consider anything older than 5.8 irrelevant unless explicitly mentioned.

      Your program produces 4 for me, whether bindmode is commented out or not (v5.12).

      Then I ask you the same question I asked the OP: Could I see your perl -V output?

      Update: I'm sure I had an old version of Perl that didn't treat ^Z specially, but it doesn't seem to be the case. It does appear to be a new fix, so disregard the request. I couldn't test until now.

        Part of the puzzle might be p5git://commit=9b1f1815, which became part of v5.14.

        The OP is using binmode. That should never stop at ^Z!

        So if Perl hits EOF due to CTRL-Z (while reading source code), then subsequently doing binmode will clear that EOF condition?

        - tye        

Re^2: Perl stops reading __DATA__ when meeting SUB character on Windows
by yfnecz (Novice) on Jan 13, 2014 at 13:18 UTC
    perl -v This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x +64-multi-thread Copyright 1987-2010, Larry Wall
    P.S. i do not personally use this perl, this is perl shipped together with our software to customers, so we can use it for executing scripts.
Re^2: Perl stops reading __DATA__ when meeting SUB character on Windows
by yfnecz (Novice) on Jan 13, 2014 at 13:19 UTC
    >perl\bin\perl -v This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x +64-multi-thread Copyright 1987-2010, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. >perl\bin\perl -V Summary of my perl5 (revision 5 version 12 subversion 1) configuration +: Platform: osname=MSWin32, osvers=6.1, archname=MSWin32-x64-multi-thread uname='Win32 strawberryperl 5.12.1.0 #1 Thu Jul 29 19:04:04 2010 x +64' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DWIN64 -DCO +NSERVATIVE -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno +-strict-al iasing -mms-bitfields -DPERL_MSVCRT_READFIX', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='4.4.3', gccosandvers='' intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='lo +ng long', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags ='-s -L"c:\strawberry64\perl\lib\CORE" -L"c:\str +awberry64\ c\lib"' libpth=c:\strawberry64\c\lib c:\strawberry64\c\x86_64-w64-mingw32\ +lib libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 +-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm + -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdl +g32 -ladva pi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lw +inmm -lver sion -lodbc32 -lodbccp32 -lcomctl32 libc=, so=dll, useshrplib=true, libperl=libperl512.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"c:\strawberry64\perl\lib\CO +RE" -L"c:\ strawberry64\c\lib"' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_64_BIT_I +NT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PE +RL_ATOF USE_SITECUSTOMIZE Built under MSWin32 Compiled at Jul 29 2010 19:18:08 @INC: ................... .

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-07-23 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (133 votes), past polls