summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-10-25 10:52:42 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-10-25 10:52:42 -0700
commit9aa8b00892d81bb5e94565d3cb9841dd57b7b9cf (patch)
tree8e675bf2f7f25b746b99e3f094065bade479e592
parent0095ccd463db264dc799ca02921528f64f1dc0b2 (diff)
downloadperl-9aa8b00892d81bb5e94565d3cb9841dd57b7b9cf.tar.gz
[perl #77688] tie $scalar can tie a handle
Make tie() distinguish between $scalar and *$scalar when $scalar holds a glob copy, by checking the FAKE flag.
-rw-r--r--pp_sys.c2
-rw-r--r--t/op/tie.t11
2 files changed, 12 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index f47395bf53..7fa9f02e31 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -826,7 +826,7 @@ PP(pp_tie)
break;
case SVt_PVGV:
case SVt_PVLV:
- if (isGV_with_GP(varsv)) {
+ if (isGV_with_GP(varsv) && !SvFAKE(varsv)) {
methname = "TIEHANDLE";
how = PERL_MAGIC_tiedscalar;
/* For tied filehandles, we apply tiedscalar magic to the IO
diff --git a/t/op/tie.t b/t/op/tie.t
index a9fb89e92a..5acd9a9db0 100644
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -953,3 +953,14 @@ print ref tied *$rin, "\n";
EXPECT
main
f
+########
+
+# tie $glob_copy vs tie *$glob_copy
+sub TIESCALAR { print "TIESCALAR\n" }
+sub TIEHANDLE{ print "TIEHANDLE\n" }
+$f = *foo;
+tie *$f, "";
+tie $f, "";
+EXPECT
+TIEHANDLE
+TIESCALAR