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

[ID 20001123.007] for loop does not return last expression

Thread Next
November 23, 2000 10:27
[ID 20001123.007] for loop does not return last expression
Message ID:

This is a bug report for perl from,
generated with the help of perlbug 1.26 running under perl 5.00502.

[Please enter your report here]

perlsub states:

       The return value of the subroutine is the value of the
       last expression evaluated.

This ends up being untrue in the case of a for loop:

  sub FOO {
    for (1,3,2) { 100 }
  $x = FOO();
  print $x;  # ''

This is not due to the implied empty continue { } block, either.

The effect is seen in 5.6 as well.

The effect is seen when the function is called in list contex:

  ($x) = FOO();
  print $x;  # still ''

The effect is NOT seen here:

  print FOO();

[Please do not change anything below this line]

Site configuration information for perl 5.00502:

Configured by jeffp at Wed Mar 24 18:23:10 EST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
    osname=solaris, osvers=2.5.1, archname=sun4-solaris
    uname='sunos friday 5.5.1 generic_103640-22 sun4m sparc sunw,sparcstation-5 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    cc='/usr/local/bin/gcc', optimize='-O', gccversion=
    ccflags ='-I/usr/local/include'
    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
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='/usr/local/bin/gcc', ldflags =' -L/usr/local/lib -L/opt/gnu/lib'
    libpth=/usr/local/lib /opt/gnu/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib -L/opt/gnu/lib'

Locally applied patches:

@INC for perl 5.00502:

Environment for perl 5.00502:
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERLOPT=-L/usr/local/lib -L/opt/gnu/lib /usr/local/lib/perl5/5.00502/sun4-solaris/auto/DynaLoader/DynaLoader.a -L/usr/local/lib/perl5/5.00502/sun4-solaris/CORE -lperl -lsocket -lnsl -ldb -ldl -lm -lc -lcrypt -I/usr/local/include -I/usr/local/lib/perl5/5.00502/sun4-solaris/CORE
    PERL_BADLANG (unset)

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