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

[ID 20001123.007] for loop does not return last expression

Thread Next
From:
jp
Date:
November 23, 2000 10:27
Subject:
[ID 20001123.007] for loop does not return last expression
Message ID:
200011231827.eANIRJk12724@friday.crusoe.net

This is a bug report for perl from jeffp@crusoe.net,
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:
  Platform:
    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
  Compiler:
    cc='/usr/local/bin/gcc', optimize='-O', gccversion=2.7.2.3
    cppflags='-I/usr/local/include'
    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/libc.so, 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:
    /usr/local/lib/perl5/5.00502/sun4-solaris
    /usr/local/lib/perl5/5.00502
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .

---
Environment for perl 5.00502:
    HOME=/home/jeffp
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/openwin/bin:/bin:/crusoe/appl/bin:/usr/local/netscape:/usr/ccs/bin:.:/home/jeffp/utils:/home/jeffp/local/bin
    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)
    SHELL=/bin/tcsh


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