develooper Front page | perl.perl5.porters | Postings from May 2007

[perl #43088] (Optimizer?) problem when combining lc,split and List::Util::first

Thread Next
Steffen_Ullrich @ genua . de
May 31, 2007 15:47
[perl #43088] (Optimizer?) problem when combining lc,split and List::Util::first
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #43088]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.35 running under perl v5.8.7.

[Please enter your report here]

In the following code $found is undef not 'foo'

 | use strict;
 | use List::Util 'first';
 | my $found = first { lc($_) eq 'foo' } split( m{[\s,]}, 'foo' );
 | print $found;

Verified against perl5.8.4, perl5.8.7 and perl5.8.8.
Verified with Scalar-List-Utils 1.19.
In perl5.9.4 this is fixed, e.g. $found is 'foo'.

If the split() is put into a temporary list which is used as an
input to first() the problem does not occur. If there is no
lc or if $_ is put in quotes (e.g. 'lc("$_")' instead of 'lc($_)')
the problem does not occur either, e.g. it returns 'foo'.

Steffen (CPAN SULLR)

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

Configured by tnt at Mon Dec 12 11:19:49 CET 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
    osname=linux, osvers=, archname=i386-linux
    uname='linux tstlnx0 #1 thu sep 15 15:43:56 cest 2005 i686 gnulinux '
    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
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-13)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    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, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.7:

Environment for perl v5.8.7:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (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