Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 555 forks source link

Input files are processed twice in slurp mode #3427

Closed p5pRT closed 20 years ago

p5pRT commented 23 years ago

Migrated from rt.perl.org#5835 (status was 'resolved')

Searchable as RT5835$

p5pRT commented 23 years ago

From joerg.krause@DaimlerChrysler.com

If the input record separator `$/' is set to `undef' in order to read through the end of file ("slurp" mode)\, every input file is tested twice instead of only once​: The first test results in a string containing the whole file - as usual -\, but then there's a second test resulting in a string which is of zero length but defined.

The problem occurs with perl 5.6.0 on AIX 4.3.3\, HP-UX 11\, IRIX 6.5 whereas perl 5.004_04 behaves as expected.

Try these examples​:

--- Example 1 ------------------------------------------------------------------ #!/usr/local/bin/perl -w

undef $/; while (\<>) {   printf   "\$ARGV​: \<%s> - Defined(\$_)​: \<%s> - Length(\$_)​: \<%s>\n"\,   $ARGV\, defined($_)\, length($_); } --- Example 2 (nearly the same) ------------------------------------------------ #!/usr/local/bin/perl -w

undef $/; for $file (@​ARGV) {   open(IN\,"\<$file");   while (\) {   printf   "\$file​: \<%s> - Defined(\$_)​: \<%s> - Length(\$_)​: \<%s>\n"\,   $file\, defined($_)\, length($_);   }   close(IN); }



Flags​:   category=core   severity=medium


Site configuration information for perl v5.6.0​:

Configured by root at Thu May 18 08​:18​:56 CEST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration​:   Platform​:   osname=irix\, osvers=6.5\, archname=IP30-irix   uname='irix64 sgiinst 6.5 01200532 ip30 '   config_args='-Dprefix=/usr/local/perl/5.6.0'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=undef d_sfio=undef uselargefiles=define   use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef   Compiler​:   cc='cc -n32'\, optimize='-O3'\, gccversion=   cppflags='-D_BSD_TYPES -D_BSD_TIME -OPT​:Olimit=0​:space=ON -I/usr/local/include -I/usr/gnu/include -DLANGUAGE_C'   ccflags ='-D_BSD_TYPES -D_BSD_TIME -woff 1009\,1110\,1174\,1184\,1552 -OPT​:Olimit=0​:space=ON -I/usr/local/include -I/usr/gnu/include -DLANGUAGE_C'   stdchar='unsigned char'\, d_stdstdio=define\, usevfork=false   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=16   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=8\, usemymalloc=n\, prototype=define   Linker and Libraries​:   ld='cc -n32'\, ldflags =' -L/usr/local/lib32 -L/usr/local/lib -Wl\,-woff\,84 -L/usr/gnu/lib'   libpth=/usr/local/lib /usr/gnu/lib /usr/lib32 /lib32 /lib /usr/lib   libs=-ldb -lm -lc   libc=/usr/lib32/libc.so\, so=so\, useshrplib=false\, libperl=libperl.a   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags=' '\, lddlflags='-n32 -shared -L/usr/local/lib32 -L/usr/local/lib -L/usr/gnu/lib'

Locally applied patches​:  


@​INC for perl v5.6.0​:   /usr/local/perl/5.6.0/lib/5.6.0/IP30-irix   /usr/local/perl/5.6.0/lib/5.6.0   /usr/local/perl/5.6.0/lib/site_perl/5.6.0/IP30-irix   /usr/local/perl/5.6.0/lib/site_perl/5.6.0   /usr/local/perl/5.6.0/lib/site_perl   .


Environment for perl v5.6.0​:   HOME=/home/krause   LANG=C   LANGUAGE (unset)   LC_CTYPE=en   LD_LIBRARY_PATH (unset)   LOGDIR (unset)   PATH=/home/krause/script​:\~/script/snap_catia​:/home/krause/bin/iris4d/IRIX64-6.5​:/home/krause/bin/iris4d​:/home/krause/bin​:/usr/local/bin​:/usr/bsd​:/usr/sbin​:/bin​:/usr/bin​:/usr/bin/X11​:/usr/freeware/bin​:.​:/usr/java/bin​:/usr/atria/bin​:/adtk/shell​:/adtk/bin_cdc   PERL_BADLANG (unset)   SHELL=/bin/tcsh

p5pRT commented 23 years ago

From @gsar

On Fri\, 16 Feb 2001 16​:51​:35 +0100\, joerg.krause@​DaimlerChrysler.com wrote​:

This is a bug report for perl from joerg.krause@​daimlerchrysler.com\, generated with the help of perlbug 1.28 running under perl v5.6.0.

If the input record separator `$/' is set to `undef' in order to read through the end of file ("slurp" mode)\, every input file is tested twice instead of on ly once​: The first test results in a string containing the whole file - as usual -\, but then there's a second test resulting in a string which is of zero length but defined.

This is a duplicate of 20000627.003\, addressed here​:

  http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-06/msg00751.html

Sarathy gsar@​ActiveState.com