develooper Front page | perl.perl5.porters | Postings from September 2000

[ID 20000922.001] Implicit comparison to $. not performed beforefilehandle read

Thread Next
September 22, 2000 09:48
[ID 20000922.001] Implicit comparison to $. not performed beforefilehandle read
Message ID:
This is a bug report for perl from,
generated with the help of perlbug 1.28 running under perl v5.6.0.

[Please enter your report here]


        FLIP .. FLOP

the manual says that if FLIP or FLOP is a constant expression, it is
implicitly compared with $. .

However, if no filehandle read has been performed, the comparison is
omitted entirely.  (I think this is undocumented.)

This means, for example, that

        perl -le 'print "*" if 0 .. 2'

        perl -le 'print "*" if ($.==0) .. 2'

produce different output, which contradicts the manual.  In the first
case, the test is skipped entirely, assumed to be false.  In the
second case, $. is read (as undef) and converted to 0, so the test is

Similarly, if warnings are enabled, the second example produces an
'uninitialized value' warning but the first does not.  

Similarly, this code

        perl -wle 'print "*" if "foo" .. "bar"'

does not generate an 'argument isn't numeric' warning.

The code that controls this is at pp_ctl.c:977 and :1054 

	if ((PL_op->op_private & OPpFLIP_LINENUM)
	  ? (PL_last_in_gv && SvIV(sv) == (IV)IoLINES(GvIOp(PL_last_in_gv)))
	  : SvTRUE(sv) ) {

I think the behavior would be more normal if the test for
PL_last_in_gv were removed, but since it is obviously intentional I
was reluctant to do that without consulting the list first.
It might change the behavior of the .. operator with respect to 'close'.

[Please do not change anything below this line]
Site configuration information for perl v5.6.0:

Configured by mjd at Wed Sep 20 15:34:29 EDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
    osname=linux, osvers=2.2.16, archname=i586-linux
    uname='linux plover 2.2.16 #97 fri jun 16 19:45:30 pdt 2000 i586 unknown '
    config_args='-Doptimize=-g -des'
    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
    cc='cc', optimize='-g', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.6.0:

Environment for perl v5.6.0:
    LANG (unset)
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About