This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revert "Revert "[perl #77688] tie $scalar can tie a handle""
authorFather Chrysostomos <sprout@cpan.org>
Fri, 13 May 2011 15:30:25 +0000 (08:30 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 11 Jun 2011 18:16:45 +0000 (11:16 -0700)
This reverts commit 7850f4d6b732ab5f426cd3bcd9757c70a46cfda1.

pp_sys.c
t/op/tie.t

index a45a8c2..31c6ea8 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -836,7 +836,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
index 44d9269..0872bde 100644 (file)
@@ -1021,3 +1021,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