# New Ticket Created by bcarter-p5p egg.flyinganvil.org
# Please include the string: [perl #46543]
# in the subject line of all future correspondence about
this issue.
# <URL: h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=46543 >
This is a bug report for perl from bcarter-p5p egg.flyinganvil.org,
generated with the help of perlbug 1.35 running under perl
v5.8.8.
------------------------------------------------------------
-----
I'm not sure if this is truly a bug with perl, or if I have
just managed
to confuse myself into a corner case of perl's parser. But
I have
distilled down what I encountered into the following minimal
script:
sub r { map [$_], 4; }
sub p { { shift; } }
print 'r = ', r(),
', r = ', { r(); },
', p() = ', p( r() ),
$/;
print " { +map [1, 2, 3, $_], (4); }" #
prints nothing
print " ${ +map [1, 2, 3, $_], (4); }" #
prints '1 2 3 4'
blead 31847 is the latest that I tested this against, but
it does not
seem to vary by perl version.
[Please do not change anything below this line]
------------------------------------------------------------
-----
---
Flags:
category=core
severity=low
---
Site configuration information for perl v5.8.8:
Configured by bcarter at Wed Oct 4 10:49:41 CDT 2006.
Summary of my perl5 (revision 5 version 8 subversion 8)
configuration:
Platform:
osname=linux, osvers=2.4.22, archname=i686-linux
uname='linux egg.flyinganvil.org 2.4.22 #6 tue sep 2
17:43:01 pdt 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='cc', ccflags ='-fno-strict-aliasing -pipe
-I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe
-I/usr/local/include'
ccversion='', gccversion='3.2.3', 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 -lgdbm -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.2.so, so=so, useshrplib=false,
libperl=libperl.a
gnulibc_version='2.3.2'
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.8:
/home/bcarter/perl5lib
/usr/local/lib/perl5/5.8.8/i686-linux
/usr/local/lib/perl5/5.8.8
/usr/local/lib/perl5/site_perl/5.8.8/i686-linux
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl
.
---
Environment for perl v5.8.8:
HOME=/home/bcarter
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:
.
PERL5LIB=/home/bcarter/perl5lib
PERL_BADLANG (unset)
SHELL=/bin/bash
|
On 10/18/07, bcarter-p5p egg.flyinganvil.org (via
RT)
<perlbug-followup perl.org>
wrote:
>
> print " { +map [1, 2, 3, $_], (4); }" #
prints nothing
> print " ${ +map [1, 2, 3, $_], (4); }" #
prints '1 2 3 4'
>
the first line, map is in scalar context, and returns 1, the
length of the
array. has not been defined yet, so nothing is printed.
try this:
$ perl -le ' = qw/a s d f/; print " { +map
[1, 2, 3, $_], (4); }" '
the second line, map is in lvalue context (a reference is
being taken to the
result)
so the scalar context takes the first of the list, just like
(qw/a s d f/)
would work
witness:
$ perl -le '($one,$two) = +map [$_],qw/A B/; print $$one'
A
$ perl -le '($one,$two) = +map [$_],qw/A B/; print $$two'
B
$ perl -le '($one,$two) = map [$_],qw/A B/; print $$two'
B
the unary plus doesn't appear to do much.
--
non-smoker since 11:31 pm october 10, 2007
"To do good in secret, and shun the world's
applause, is the surest testimony of a virtuous
heart and self-approving conscience."
-- John Polidori ( http://tinyurl.com/ytm8ba
a> )
|