develooper Front page | perl.perl5.porters | Postings from October 2011

[perl #101938] Oddity of /p

Thread Previous | Thread Next
From:
Eric Brine
Date:
October 21, 2011 21:08
Subject:
[perl #101938] Oddity of /p
Message ID:
rt-3.6.HEAD-31297-1319256491-760.101938-75-0@perl.org
# New Ticket Created by  "Eric Brine" 
# Please include the string:  [perl #101938]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=101938 >


This is a bug report for perl from ikegami@adaelis.com,
generated with the help of perlbug 1.39 running under perl 5.14.0.
-----------------------------------------------------------------

Hi,

Does the "p" modifier apply to the operator (like "o") or the pattern (like
"s")? It seems to me it applies to the operator.

That said, (?:) supports p, although it has no effect (sometimes with
warning, sometimes without).

>perl -wE"'x' =~ /x/p or die; say ${^MATCH} // '-';"
x

>perl -wE"'x' =~ /(?p:x)/ or die; say ${^MATCH} // '-';"
-

>perl -wE"'x' =~ /(?-p:x)/p or die; say ${^MATCH} // '-';"
Useless use of (?-p) in regex; marked by <-- HERE in m/(?-p <-- HERE :x)/ at
-e line 1.
x

Except sometimes it does have an effect.

>perl -wE"$re=qr/x/p; 'x' =~ /${re}/ or die; say ${^MATCH} // '-';"
x

>perl -wE"$re=qr/x/p; 'xy' =~ /${re}y/ or die; say ${^MATCH} // '-';"
-

And then there's the case where (?-p:) warns even though it appears to work.

>perl -wE"$re=qr/x/p; 'x' =~ /$re/ or die; say ${^MATCH} // '-';"
x

>perl -wE"$re=qr/x/p; 'x' =~ /(?-p:$re)/ or die; say ${^MATCH} // '-';"
Useless use of (?-p) in regex; marked by <-- HERE in m/(?-p <-- HERE
:(?^up:x))/ at -e line 1.
-

>From a user's perspective, none of this makes no sense. It was probably done
this way so C<< $re = qr/.../p; $_ =~ $re >> works, but that doesn't really
make sense either. "p" should be a m// modifier, it shouldn't be qr//
modifier, and it should be allowed in (?:).

- Eric


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.14.0:

Configured by gecko at Thu May 12 09:33:39 2011.

Summary of my perl5 (revision 5 version 14 subversion 0) configuration:

  Platform:
    osname=MSWin32, osvers=5.2, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='C:/Progs/PERL51~4/site/bin/gcc.exe', ccflags ='-DNDEBUG -DWIN32
-D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T
-DHASATTRIBUTE -fno-strict-aliasing -mms-bitfields',
    optimize='-O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='3.4.5 (mingw-vista special r3)',
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='C:\Progs\PERL51~4\site\bin\g++.exe', ldflags
='-L"C:\Progs\perl5140-ap1400\lib\CORE"'
    libpth=\lib
    libs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm
-lversion -lodbc32 -lodbccp32 -lcomctl32 -lmsvcrt
    perllibs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm
-lversion -lodbc32 -lodbccp32 -lcomctl32 -lmsvcrt
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl514.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -L"C:\Progs\perl5140-ap1400\lib\CORE"'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY

---
@INC for perl 5.14.0:
    C:/Progs/perl5140-ap1400/site/lib
    C:/Progs/perl5140-ap1400/lib
    .

---
Environment for perl 5.14.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=c:\bin;C:\Progs\perl5140-ap1400\site\bin;C:\Progs\perl5140-ap1400\bin;...
    PERL_BADLANG (unset)
    SHELL (unset)

Thread Previous | 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