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

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

Thread Previous | Thread Next
Ulrich Windl
February 24, 2006 06:05
[perl #38625] true semantics of "/$pat/o"
Message ID:
# New Ticket Created by  "Ulrich Windl" 
# Please include the string:  [perl #38625]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
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]
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:
    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 -'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define 
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags =' -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE 
    optimize='-fast +DSitanium2 +Ofltacc=strict',
-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/, so=so, useshrplib=true,
  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:
    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

@INC for perl v5.8.3:

Environment for perl v5.8.3:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About