develooper Front page | perl.perl5.porters | Postings from July 2003

[perl #23180] "target is too short" optimization does not reset pos()

July 31, 2003 06:15
[perl #23180] "target is too short" optimization does not reset pos()
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #23180]
# 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.26 running under perl 5.00503.

[Please enter your report here]

Please consider this short example:

#!/usr/bin/perl -l

for ("f") {
  m/./g  or print "1st match failed"; print pos || "<undef>";
  m/../g or print "2nd match failed"; print pos || "<undef>";

This outputs:

2nd match failed

Since the second match failed, pos() should be undefined after

Changing the second match to "m/./g" will show pos has been reset

This behaviour is present in all versions of perl I've access
to up to and including 5.8.0

I should mention that it was Steve Grazzini <> who
really identified where the problem probably was and who provided
the above example. The only credit I will take is stumbling upon
pos() behaving badly and reporting an case to comp.lang.perl.misc

[Please do not change anything below this line]

Site configuration information for perl 5.00503:

Configured by beheer at Tue Jul  6 14:27:38 MET DST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
    osname=solaris, osvers=2.7, archname=sun4-solaris
    uname='sunos white 5.7 generic_106541-04 sun4u sparc sunw,ultra-250 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    cc='gcc', optimize='-O2', gccversion=2.8.1
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:

@INC for perl 5.00503:

Environment for perl 5.00503:
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About