develooper Front page | perl.perl5.porters | Postings from March 2003

[perl #21628] Bug in while loop

Thread Next
From:
Matt Sergeant
Date:
March 20, 2003 08:26
Subject:
[perl #21628] Bug in while loop
Message ID:
rt-21628-53874.7.4878491878458@bugs6.perl.org
# New Ticket Created by  Matt Sergeant 
# Please include the string:  [perl #21628]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21628 >


This is a bug report for perl from matt@sergeant.org,
generated with the help of perlbug 1.34 running under perl v5.8.0.


-----------------------------------------------------------------
[Please enter your report here]

Under perl 5.8.0 the following code resets the variable to undef
when it exits the loop. Under 5.6.0, 5.6.1 and 5.005 it does
what you would expect, and leave the variable in tact:

#!perl -w
my ($t, $count);
while ($t .= <DATA>) {
  last if $count++ > 10;
}
print "T is: $t\n";

__DATA__
one
two
three

=================

Changing the while loop to be:

while (<DATA>) {
  $t .= $_;
  last if $count++ > 10;
}

makes the problem go away.


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.0:

Configured by afaby at Fri Jul 19 18:03:18 PDT 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=darwin, osvers=5.5, archname=darwin
    uname='darwin mercury 5.5 darwin kernel version 5.5: thu may 30
14:51:26 pdt 2002; root:xnuxnu-201.42.3.obj~1release_ppc power macintosh
powerpc '
    config_args='-Dprefix=/opt/perl'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-pipe -fno-common -no-cpp-precomp
-fno-strict-aliasing',
    optimize='-O3',
    cppflags='-no-cpp-precomp -pipe -fno-common -no-cpp-precomp
-fno-strict-aliasing'
    ccversion='', gccversion='2.95.2 19991024 (release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -flat_namespace'
    libpth=/usr/lib
    libs=-lm -lc
    perllibs=-lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true,
libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -flat_namespace -bundle -undefined
suppress'

Locally applied patches:


---
@INC for perl v5.8.0:
    /sw/lib/perl5/darwin
    /sw/lib/perl5
    /opt/perl/lib/5.8.0/darwin
    /opt/perl/lib/5.8.0
    /opt/perl/lib/site_perl/5.8.0/darwin
    /opt/perl/lib/site_perl/5.8.0
    /opt/perl/lib/site_perl
    .

---
Environment for perl v5.8.0:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/mattserg
    LANG=en_US
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/sw/lib
    LOGDIR (unset)

PATH=/sw/bin:/sw/sbin:/sw/bin:/sw/sbin:/Users/mattserg/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin
    PERL5LIB=/sw/lib/perl5
    PERL_BADLANG (unset)
    SHELL=/sw/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About