perl5
perl5 copied to clipboard
\U and \L in interpolated strings don't actually stack
Description Perl the documentation, in string interpolation \U and \L stack, but it doesn't actually work. "\L, \U, \F, and \Q can stack, in which case you need one \E for each"
Steps to Reproduce print "\UUpPeR\LLOWER\EuPpEr\E\n"; UPPERloweruPpEr
Expected behavior UPPERlowerUPPER
The first \E should pop the \L, leaving the \U operator in effect until the second \E.
Perl configuration
Summary of my perl5 (revision 5 version 34 subversion 0) configuration:
Platform:
osname=msys
osvers=3.1.7-340.x86_64
archname=x86_64-msys-thread-multi
uname='msys_nt-10.0-14393 fv-az123-95 3.1.7-340.x86_64 2021-03-26 22:17 utc x86_64 msys '
config_args='-des -Dusethreads -Doptimize=-march=x86-64 -mtune=generic -O2 -pipe -Dprefix=/usr -Dvendorprefix=/usr -Dprivlib=/usr/share/perl5/core_perl -Darchlib=/usr/lib/perl5/core_perl -Dsitelib=/usr/share/perl5/site_perl -Dsitearch=/usr/lib/perl5/site_perl -Dvendorlib=/usr/share/perl5/vendor_perl -Dvendorarch=/usr/lib/perl5/vendor_perl -Dscriptdir=/usr/bin/core_perl -Dsitescript=/usr/bin/site_perl -Dvendorscript=/usr/bin/vendor_perl -Dinc_version_list=none -Dman1ext=1perl -Dman3ext=3perl -Darchname=-msys-threads -Dmyarchname=-msys -Dlibperl=msys-perl5_34.dll -Dcc=gcc -Dld=g++ -Accflags=-march=x86-64 -mtune=generic -O2 -pipe -fwrapv'
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='gcc'
ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fwrapv -fno-strict-aliasing -fstack-protector-strong -D_FORTIFY_SOURCE=2'
optimize='-march=x86-64 -mtune=generic -O2 -pipe'
cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fwrapv -fno-strict-aliasing -fstack-protector-strong'
ccversion=''
gccversion='10.2.0'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='g++'
ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong'
libpth=/usr/lib
libs=-lpthread -ldl -lcrypt
perllibs=-lpthread -ldl -lcrypt
libc=/usr/lib/libmsys-2.0.a
so=dll
useshrplib=true
libperl=msys-perl5_34.dll
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags=' --shared -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_TIMES
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
USE_REENTRANT_API
USE_THREAD_SAFE_LOCALE
Built under msys
Compiled at Jul 22 2021 12:31:47
@INC:
/usr/lib/perl5/site_perl
/usr/share/perl5/site_perl
/usr/lib/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib/perl5/core_perl
/usr/share/perl5/core_perl
On Mon, Apr 25, 2022 at 09:21:00PM -0700, Joe Cool wrote:
Description Perl the documentation, in string interpolation \U and \L stack, but it doesn't actually work. "\L, \U, \F, and \Q can stack, in which case you need one \E for each"
Looking at the src code in yyl_interpcasemod(), in the case of a new \L, \U or \F, it quite explicitly looks for any existing L/U/F on the casestack, and if so, pops it before pushing the new one. So it appears to be deliberate behaviour not to stack. (and has been like that since 5.000.)
I guess we need to fix the docs rather than change perl's behaviour.
-- More than any other time in history, mankind faces a crossroads. One path leads to despair and utter hopelessness. The other, to total extinction. Let us pray we have the wisdom to choose correctly. -- Woody Allen
On 4/28/22 03:41, iabyn wrote:
On Mon, Apr 25, 2022 at 09:21:00PM -0700, Joe Cool wrote:
Description Perl the
in string interpolation \U and \L stack, but it doesn't actually work. "\L, \U, \F, and \Q can stack, in which case you need one \E for each"
Looking at the src code in yyl_interpcasemod(), in the case of a new \L, \U or \F, it quite explicitly looks for any existing L/U/F on the casestack, and if so, pops it before pushing the new one. So it appears to be deliberate behaviour not to stack. (and has been like that since 5.000.)
I guess we need to fix the docs rather than change perl's behaviour.
This is actually a sore point. The behavior is inconsistent. There are plenty of tickets on it; this one may well be a duplicate. It is on my todo list, but quite low in priority, to go through them and propose an approach to making things consistent, which might very well lead to some deprecation cycles.
rjbs was quite keen at one time to have this done, IIRC.
Anyone who wants to take this on, I owe you a beer or two.
Maybe just document that only \Q and {\L, \U, \F} can be nested and that \L \U and \F each get an implicit \E if another command from that set is seen?
It's worse than that
Here are some tickets #8848 #11145 #18981
Issue #8848 looks unrelated, I think it was typo'ed and that it should've been: #8846