Package: perl-base
Version: 5.18.0-3
Severity: normal
File: /usr/bin/perl

If a regex is precompiled with qr//, but without /p, and then used in
$text =~ /$pat/p, the ${^POSTMATCH} variable is undefined.  If I use
qr//p instead, everything works fine.  This did work in Perl 5.14, so I
expect that despite the bad style, it should work in Perl 5.18.

The attached test case will die in Perl 5.18.

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.10-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages perl-base depends on:
ii  dpkg   1.17.0
ii  libc6  2.17-7

perl-base recommends no packages.

Versions of packages perl-base suggests:
ii  perl  5.18.0-3

-- no debconf information

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
#!/usr/bin/perl

use v5.14;
use strict;
use warnings;

transform_named_escapes("foo\\n(AB", "n", "n");

sub transform_named_escapes {
	my ($text, $char, $type) = @_;
	my $ec = "\\";

	# The more complex forms are first because \X will match a ( or [.
	my $pat = qr/\Q$ec$char\E(\((\X{2})|\[(\X*?)\]|(\X))/;

	# We might end up with something like \*(\*(NA.  In this case, parse the
	# second escape first, and then stick that into the proper place.
	while ($text =~ /$pat/p) {
		my $desc = $1;
		my $name = $2 || $3 || $4;
		my ($pre, $post) = (${^PREMATCH}, ${^POSTMATCH});
		die unless defined ${^POSTMATCH};
	}

	return $text;
}

Attachment: signature.asc
Description: Digital signature

Reply via email to