summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-18 20:34:43 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-09-18 21:30:48 -0700
commitd8c6310a4f016fa2e6af68b606ee53084fbf4a8a (patch)
tree87ae75029c6185644f02939acacc1e28f63f3d90 /gv.c
parent99f74b09f61407826aeb0bf8eabad6e2e628c02b (diff)
downloadperl-d8c6310a4f016fa2e6af68b606ee53084fbf4a8a.tar.gz
[perl #121638] Make ‘Global symbol’ message more newbie-friendly
by suggesting the declaration of a lexical variable, but without removing the ‘Global symbol’ part, since much code no doubt depends on its presence.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index b61b21c50b..4930c0321c 100644
--- a/gv.c
+++ b/gv.c
@@ -1733,7 +1733,12 @@ S_find_default_stash(pTHX_ HV **stash, const char *name, STRLEN len,
if (add && !PL_in_clean_all) {
SV * const err = Perl_mess(aTHX_
"Global symbol \"%s%"UTF8f
- "\" requires explicit package name",
+ "\" requires explicit package name (did you forget to "
+ "declare \"my %s%"UTF8f"\"?)",
+ (sv_type == SVt_PV ? "$"
+ : sv_type == SVt_PVAV ? "@"
+ : sv_type == SVt_PVHV ? "%"
+ : ""), UTF8fARG(is_utf8, len, name),
(sv_type == SVt_PV ? "$"
: sv_type == SVt_PVAV ? "@"
: sv_type == SVt_PVHV ? "%"