X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=gv.c;h=aa2befc54a109701e2c0ff2025729c4276c6c166;hb=0a76ff6528f0ab52947d4f1b9664310ce137b9a0;hp=8a9b803b1c953d439047aac196e4df9596d9a4d2;hpb=13207a7148ab5967a6d91a9acb60e5e292572de2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/gv.c b/gv.c index 8a9b803..aa2befc 100644 --- a/gv.c +++ b/gv.c @@ -693,6 +693,10 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) } len = namend - name; + /* $_ should always be in main:: even when our'ed */ + if (*name == '_' && !name[1]) + stash = PL_defstash; + /* No stash in name, so see how we can default */ if (!stash) { @@ -720,7 +724,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) if (global) stash = PL_defstash; - else if ((COP*)PL_curcop == &PL_compiling) { + else if (IN_PERL_COMPILETIME) { stash = PL_curstash; if (add && (PL_hints & HINT_STRICT_VARS) && sv_type != SVt_PVCV && @@ -761,12 +765,15 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) if (!stash) { if (add) { - qerror(Perl_mess(aTHX_ + register SV *err = Perl_mess(aTHX_ "Global symbol \"%s%s\" requires explicit package name", (sv_type == SVt_PV ? "$" : sv_type == SVt_PVAV ? "@" : sv_type == SVt_PVHV ? "%" - : ""), name)); + : ""), name); + if (USE_UTF8_IN_NAMES) + SvUTF8_on(err); + qerror(err); stash = GvHV(gv_fetchpv("::", GV_ADDMULTI, SVt_PVHV)); } else