This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
gv.c: Explain the purpose of the <none>:: stash a bit.
authorBrian Fraser <fraserbn@gmail.com>
Fri, 10 May 2013 07:17:58 +0000 (04:17 -0300)
committerTony Cook <tony@develop-help.com>
Wed, 11 Sep 2013 00:28:29 +0000 (10:28 +1000)
It's primarily a historical oddity. Its main purpose is to store
variables after an exception from 'use strict "vars"':

    eval q{ use strict; $foo = 1 };
    warn keys %{"<none>::"};

gv.c

diff --git a/gv.c b/gv.c
index c84e569..afa6a5e 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -1614,6 +1614,11 @@ S_find_default_stash(pTHX_ HV **stash, const char *name, STRLEN len,
             if (is_utf8)
                 SvUTF8_on(err);
             qerror(err);
+            /* To maintain the output of errors after the strict exception
+             * above, and to keep compat with older releases, rather than
+             * placing the variables in the pad, we place
+             * them in the <none>:: stash.
+             */
             gv = gv_fetchpvs("<none>::", GV_ADDMULTI, SVt_PVHV);
             if (!gv) {
                 /* symbol table under destruction */