develooper Front page | perl.perl5.porters | Postings from February 2006

[perl #38625] true semantics of "/$pat/o"

Thread Previous | Thread Next
From:
Ulrich Windl
Date:
February 24, 2006 06:05
Subject:
[perl #38625] true semantics of "/$pat/o"
Message ID:
rt-3.0.11-38625-130554.3.49985571850155@perl.org
# New Ticket Created by  "Ulrich Windl" 
# Please include the string:  [perl #38625]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=38625 >



This is a bug report for perl from Ulrich.Windl@rz.uni-regensburg.de,
generated with the help of perlbug 1.34 running under perl v5.8.3.


-----------------------------------------------------------------
[Please enter your report here]
The exact semantics of /$pattern/o is not clear: The docs say the pattern
is compiled only once. It may seem clear if considering static blocks of
code. However:

{
	my foo = "abc";

	... /$foo/o
}

{
	my foo = "cde";
	... /$foo/o
}

Naturally one would expect that in different blocks each $foo pattern is
compiled once (twice alltogether in this example).

Now consider this:

sub make_matcher($)
{
    my $epattern = shift;

    if ($epattern =~ /^!./) {
        $epattern = substr($epattern, 1);

        return sub {
            my $arg = shift;

            return $arg !~ /$epattern/o;
        };
    } else {
        return sub {
            my $arg = shift;

            return $arg =~ /$epattern/o;
        };
    }
}

my $matcher = make_matcher("abc")
... &$matcher("test")

my $matcher = make_matcher("!cde")
... &$matcher("test")

Isn't $epattern a different variable for each call of make_matcher()?
Thus it should be compiled to a new pattern (when creating a sub), but not
when the returned sub is called.

However all subsequent matchers use the first match pattern. I thinks that's
a bug.

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

Configured by ActiveState at Thu May 27 17:36:19 PDT 2004.

Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
  Platform:
    osname=hpux, osvers=11.22, archname=IA64.ARCHREV_0-thread-multi
    uname='hp-ux bigsur03 b.11.22 u ia64 1800516905 unlimited-user license '
    config_args='-ders -Dcc=cc -Accflags=-DNO_HASH_SEED -Dusethreads -Duseithreads 
-Ud_sigsetjmp -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Dd_attribut=undef -
Dd_u32align=define -Doptimize=-fast +DSitanium2 +Ofltacc=strict -Duselargefiles -
Dinc_version_list=5.8.2/$archname 5.8.2 5.8.1/$archname 5.8.1 5.8.0/$archname 
5.8.0 -Duseshrplib -Dprefix=/opt/perl -Dcf_by=ActiveState -
Dcf_email=support@ActiveState.com'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=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='cc', ccflags =' -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE 
-Wl,+vnocompatwarnings -DNO_HASH_SEED -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 
',
    optimize='-fast +DSitanium2 +Ofltacc=strict',
    cppflags='-D__STDC_EXT__ -D_HPUX_SOURCE -D_POSIX_C_SOURCE=199506L -D_REENTRANT 
-D_HPUX_SOURCE -Wl,+vnocompatwarnings -DNO_HASH_SEED'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/usr/bin/ld', ldflags =' -L/usr/lib/hpux32'
    libpth=/usr/lib/hpux32 /lib /usr/lib /usr/ccs/lib /usr/local/lib
    libs=-lnsl -lnm -lndbm -ldl -ldld -lm -lsec -lpthread -lc
    perllibs=-lnsl -lnm -ldl -ldld -lm -lsec -lpthread -lc
    libc=/usr/lib/hpux32/libc.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred 
'
    cccdlflags='+Z', lddlflags='-b +vnocompatwarnings -L/usr/lib/hpux32'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    22218 Remove the caveat about detached threads crashing on Windows
    22201 Avoid threads+win32 crash by freeing Perl interpreter slightly later
    22169 Display 'out of memeory' errors using low-level I/O
    22159 Upgrade to Time::Hires 1.55
    22120 Make 'Configure -Dcf_by=...' work
    22051 Upgrade to Time::HiRes 1.54
    21540 Fix backward-compatibility issues in if.pm

---
@INC for perl v5.8.3:
    /opt/perl/lib/5.8.3/IA64.ARCHREV_0-thread-multi
    /opt/perl/lib/5.8.3
    /opt/perl/lib/site_perl/5.8.3/IA64.ARCHREV_0-thread-multi
    /opt/perl/lib/site_perl/5.8.3
    /opt/perl/lib/site_perl
    .

---
Environment for perl v5.8.3:
    HOME=/home/windl
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=/usr/local/bin:/usr/local/bin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/con
trib/Q4/bin:/opt/perl/bin:/opt/ipf/bin:/opt/hparray/bin:/opt/nettladm/bin:/opt/fcm
s/bin:/opt/sec_mgmt/bastille/bin:/opt/resmon/bin:/opt/gnome/bin:/usr/bin/X11:/opt/
ignite/bin:/usr/contrib/kwdb/bin:/opt/wbem/bin:/opt/wbem/sbin:/opt/graphics/common
/bin:/opt/sec_mgmt/spc/bin:/opt/java1.4/jre/bin:/opt/spb/bin:/opt/hpsmh/bin:/opt/u
pgrade/bin:/opt/gwlm/bin:/opt/mozilla:/usr/contrib/bin/X11:/opt/ssh/bin
    PERL_BADLANG (unset)
    SHELL=/usr/bin/csh



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