Front page | perl.perl5.porters |
Postings from April 2003
[perl #22027] undef appears as scalar return value for a list
Thread Next
From:
Mike Stok
Date:
April 24, 2003 07:30
Subject:
[perl #22027] undef appears as scalar return value for a list
Message ID:
rt-22027-55828.8.59218932203433@bugs6.perl.org
# New Ticket Created by Mike Stok
# Please include the string: [perl #22027]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22027 >
This is a bug report for perl from mike@stok.co.uk,
generated with the help of perlbug 1.34 running under perl v5.8.0.
-----------------------------------------------------------------
[Please enter your report here]
I may be being an idiot here, so feel free to tell me that I am.
use strict;
use warnings;
sub show {
print defined $_[0] ? $_[0] : '(undef)', "\n";
}
my $rv = ('a', 'b', 'c');
show $rv;
my $rv2 = ('a', 'b', 'c', ());
show $rv2;
I would have expected $rv2 to be 'c' as I thought ('a', 'b', 'c', ()) should
be flattened to ('a', 'b', 'c'). The warnings indicate that in the first
case two values are useless, and in the second three values are useless.
Things like
@array = ('a', 'b', 'c', ()); # => ('a', 'b', 'c')
$scalar = ('a', 'b', 'c', ())[-1]; # => 'c'
seem to work as I would expect.
Mike
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
Site configuration information for perl v5.8.0:
Configured by mike at Sun Mar 30 09:26:26 EST 2003.
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.21-0.13mdkenterprise, archname=i686-linux
uname='linux ratdog.stok.co.uk 2.4.21-0.13mdkenterprise #1 smp fri mar 14 14:40:17 est 2003 i686 unknown unknown gnulinux '
config_args=''
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='gcc', ccflags ='-I/usr/local/mike/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O3 -march=athlon-xp -pipe',
cppflags='-I/usr/local/mike/include'
ccversion='', gccversion='3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)', 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='gcc', ldflags ='-L/usr/local/mike/lib -L/usr/local/lib'
libpth=/usr/local/mike/lib /usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.3.1.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.3.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/mike/lib -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.0:
/usr/local/mike/lib/perl5/5.8.0/i686-linux
/usr/local/mike/lib/perl5/5.8.0
/usr/local/mike/lib/perl5/site_perl/5.8.0/i686-linux
/usr/local/mike/lib/perl5/site_perl/5.8.0
/usr/local/mike/lib/perl5/site_perl
.
---
Environment for perl v5.8.0:
HOME=/home/mike
LANG=en_CA
LANGUAGE=en_CA:en_US:en
LC_ADDRESS=en_CA
LC_COLLATE=en_CA
LC_CTYPE=en_CA
LC_IDENTIFICATION=en_CA
LC_MEASUREMENT=en_CA
LC_MESSAGES=en_CA
LC_MONETARY=en_CA
LC_NAME=en_CA
LC_NUMERIC=en_CA
LC_PAPER=en_CA
LC_TELEPHONE=en_CA
LC_TIME=en_CA
LD_LIBRARY_PATH=/usr/local/mike/lib
LOGDIR (unset)
PATH=/usr/local/mike/bin:/usr/java/j2re1.4.1_02/bin:/usr/local/mike/Acrobat5/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/home/mike/bin
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Next
-
[perl #22027] undef appears as scalar return value for a list
by Mike Stok