Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

5.005_57: Regex behaves incorrectly #42

Closed p5pRT closed 20 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#844 (status was 'resolved')

Searchable as RT844$

p5pRT commented 24 years ago

From @mjdominus

This should print `!!!' before it does anything else\, and in this case the regex should match. (It's a slightly modified version of the regex from page 200 of _Perl Cookbook_; it should match any string that does not end in `foo'.

However\, it doesn't match\, and it doesn't print `!!!' either.

If I remove the $ from the end of the regex\, it prints `!!!'. If I remove (?{print "$2 "}) from the middle\, it prints `!!!'. If I change the target string from `xf' to `x'\, it prints `!!!'.

Summary of my perl5 (revision 5.0 version 5 subversion 57) configuration​:   Platform​:   osname=linux\, osvers=2.0.35\, archname=i586-linux   uname='linux plover 2.0.35 #2 mon oct 26 21​:26​:00 cst 1998 i586 unknown '   config_args='-Doptimize=-g -des'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef useperlio=undef d_sfio=undef   use64bits=undef usemultiplicity=undef   Compiler​:   cc='cc'\, optimize='-g'\, gccversion=egcs-2.90.29 980515 (egcs-1.0.3 release)   cppflags='-Dbool=char -DHAS_BOOL -DDEBUGGING -I/usr/local/include'   ccflags ='-Dbool=char -DHAS_BOOL -DDEBUGGING -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=12   alignbytes=4\, usemymalloc=n\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -L/usr/local/lib'   libpth=/usr/local/lib /shlib /lib /usr/lib   libs=-lndbm -lgdbm -ldbm -ldb -ldl -lm -lc   libc=/lib/libc-2.0.7.so\, so=so\, useshrplib=false\, libperl=libperl.a   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-rdynamic'   cccdlflags='-fpic'\, lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl)​:   Compile-time options​: DEBUGGING   Built under linux   Compiled at May 25 1999 16​:00​:13   @​INC​:   /usr/local/lib/perl5/5.00557/i586-linux   /usr/local/lib/perl5/5.00557   /usr/local/lib/perl5/site_perl/5.00557/i586-linux   /usr/local/lib/perl5/site_perl/5.00557   .

Mark-Jason Dominus mjd@​plover.com

p5pRT commented 24 years ago

From [Unknown Contact. See original ticket]

Mark\,

The code you gave​:

  #!/usr/bin/perl -w

  $z = ("xf" =~ m{^
  (?{print "!!!\n"})   (   (   (?!foo$ )   .   ) (?{print "$2 "})   *   )   $   }x);

  print "$z\n";

now emits a warning (in 5.6-RC2)​:

(?{print "$2 "}) * matches null string many times at /tmp/asdf line 13.

I don't know whether this helps your code or reflects a different bug :-)

Nat

p5pRT commented 24 years ago

From @mjdominus

Mark\,

The code you gave​:

The warning makes sense\, and I can't imagine what possessed me to put a * there. Can you send me some private email to remind me of the context?