summaryrefslogtreecommitdiff
path: root/t/re/subst.t
diff options
context:
space:
mode:
Diffstat (limited to 't/re/subst.t')
-rw-r--r--t/re/subst.t30
1 files changed, 29 insertions, 1 deletions
diff --git a/t/re/subst.t b/t/re/subst.t
index d32e7b8aef..6224d64ff2 100644
--- a/t/re/subst.t
+++ b/t/re/subst.t
@@ -11,7 +11,7 @@ BEGIN {
require './loc_tools.pl';
}
-plan( tests => 271 );
+plan( tests => 274 );
$_ = 'david';
$a = s/david/rules/r;
@@ -1119,3 +1119,31 @@ SKIP: {
{stderr => 1 },
'[perl #129038 ] s/\xff//l no longer crashes');
}
+
+{
+ # RT #23624 scoping of @+/@- when used with tie()
+ #! /usr/bin/perl -w
+
+ package Tie::Prematch;
+ sub TIEHASH { bless \my $dummy => __PACKAGE__ }
+ sub FETCH { return substr $_[1], 0, $-[0] }
+
+ package main;
+
+ tie my %pre, 'Tie::Prematch';
+ my $foo = 'foobar';
+ $foo =~ s/.ob/$pre{ $foo }/;
+ is($foo, 'ffar', 'RT #23624');
+
+ $foo = 'foobar';
+ $foo =~ s/.ob/tied(%pre)->FETCH($foo)/e;
+ is($foo, 'ffar', 'RT #23624');
+
+ tie %-, 'Tie::Prematch';
+ $foo = 'foobar';
+ $foo =~ s/.ob/$-{$foo}/;
+ is($foo, 'ffar', 'RT #23624');
+
+ undef *Tie::Prematch::TIEHASH;
+ undef *Tie::Prematch::FETCH;
+}