Package: perl Version: 5.14.2-6 Severity: normal Dear Maintainer,
The negative look-behind assertion does not work correctly before $ (the end-of-line assertion). I expect to be able to say "match lines that do not end in bar" using the regex /(?<!bar)$/ . However this does not work: % (echo foo; echo bar; echo foobaz) | perl -ne 'print if(/(?<!bar)$/)' foo bar foobaz % It should not have printed "bar" above. A similar pattern using /^(?!bar)/ works to say "lines that do not start with bar", and negative look-behind works before a string: # negative lookahead % (echo foo; echo bar; echo foobaz) | perl -ne 'print if(/^(?!foo)/)' bar % # negative lookbehind before string % (echo foo; echo bar; echo foobaz) | sed 's/$/x/g' | \ perl -ne 'print if(/(?<!bar)x$/)' foox foobazx % I found a workaround that may shed light on the root cause of the problem. Normally /$/ matches the end of a string or the line-ending character at the end of a <> string, and regex behavior with $ is not changed by chomp()ing the line-ending-character away. But in this case, there is a difference. If I "chomp;" before matching, the negative look-behind assertion works correctly: % (echo foo; echo bar; echo foobaz) | perl -ne 'chomp; print if(/(?<!bar)$/)' foofoobaz % Note that it did not print "bar" above, correctly implementing the behavior documented in perlre(1). -- System Information: Debian Release: wheezy/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 3.4.0-rc4-00095-g95f7147 (SMP w/4 CPU cores) Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages perl depends on: ii libbz2-1.0 1.0.6-1 ii libc6 2.13-26 ii libdb5.1 5.1.29-1 ii libgdbm3 1.8.3-10 ii perl-base 5.14.2-6 ii perl-modules 5.14.2-6 ii zlib1g 1:1.2.3.4.dfsg-3 Versions of packages perl recommends: ii netbase 4.47 Versions of packages perl suggests: ii libterm-readline-gnu-perl | libterm-readline-perl-perl <none> ii make 3.81-8.1 ii perl-doc 5.14.2-6 -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org