summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-08-10 09:49:28 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-08-11 07:54:42 -0700
commit1c75beb82e2bc71836b8b226cb4e976792d1967c (patch)
treeabb0787518fa956de23734503525ef4d1a1868c5 /mg.c
parentae7a8a78f1dbd467b63525c5201b8377dc705e7b (diff)
downloadperl-1c75beb82e2bc71836b8b226cb4e976792d1967c.tar.gz
Modifying ${^OPEN} changes the value of $^H:
$ ./perl -le 'BEGIN { print $^H; ${^OPEN} = "a\0b"; print $^H}' 256 917760 So changing $^H back should change the value of ${^OPEN} back to undef, right? $ ./perl -le 'BEGIN { ${^OPEN} = "a\0b"; $^H=256; print ${^OPEN}//"undef"}' ab $ ./perl -le 'BEGIN { ${^OPEN} = "a\0b"; $^H=256;}BEGIN{ print ${^OPEN}//"undef"}' undef Apparently you have to hop from one BEGIN block to another to see the changes. This happens because compile-time hints are stored in PL_hints (which $^H sets) but ${^OPEN} looks in PL_compiling.cop_hints. Setting ${^OPEN} sets both. The contents of PL_hints are assigned to PL_compiling.cop_hints at certain points (the start of a BEGIN block sees the right value because newSTATEOP sets it), but the two are not always kept in synch. The smallest fix here is to have $^H set PL_compiling.cop_hints as well as PL_hints, but the ultimate fix--to come later--is to merge the two and stop storing hints in two different places.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mg.c b/mg.c
index 0ce58ab5d2..b4c06923ee 100644
--- a/mg.c
+++ b/mg.c
@@ -2590,6 +2590,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
break;
case '\010': /* ^H */
PL_hints = SvIV(sv);
+ CopHINTS_set(&PL_compiling, PL_hints);
break;
case '\011': /* ^I */ /* NOT \t in EBCDIC */
Safefree(PL_inplace);