develooper Front page | perl.perl5.porters | Postings from September 2001

[PATCH gv.c] make __ANON__ global

Thread Next
From:
Robin Barker
Date:
September 26, 2001 10:20
Subject:
[PATCH gv.c] make __ANON__ global
Message ID:
200109261656.RAA27762@tempest.npl.co.uk
I know C<package;> is deprecated but this error confused me.

	% ./perl -e 'package; sub {}'
	Global symbol "__ANON__" requires explicit package name at -e line 1.
	Execution of -e aborted due to compilation errors.

It looks as if __ANON__ should be global, anyway.  So that it is what
the attached patch does.  If this is the wrong approach tell me. :-)

Robin 

--- gv.c.orig
+++ gv.c
@@ -656,7 +656,7 @@
 		  strEQ(name, "ARGVOUT")))
 		    global = TRUE;
 	    }
-	    else if (*name == '_' && !name[1])
+	    else if (*name == '_' && (!name[1] || strEQ(name,"__ANON__")))
 		global = TRUE;
 
 	    if (global)
--- t/op/anonsub.t.orig
+++ t/op/anonsub.t
@@ -97,3 +97,8 @@
 X();
 EXPECT
 ok 1
+########
+package;
+print sub { return "ok 1\n" } -> ();
+EXPECT
+ok 1
--- t/op/runlevel.t.orig
+++ t/op/runlevel.t
@@ -309,6 +309,7 @@
 eval { die };
 &{sub { eval 'die' }}();
 sub foo { eval { die } } foo();
+{package rmb; sub{ eval{die} } ->() };	# check __ANON__ is global	
 EXPECT
 In DIE
 main|-|8|(eval)
@@ -318,6 +319,9 @@
 In DIE
 main|-|10|(eval)
 main|-|10|main::foo
+In DIE
+rmb|-|11|(eval)
+rmb|-|11|main::__ANON__
 ########
 package TEST;

End of patch 

-- 
Robin Barker                        | Email: Robin.Barker@npl.co.uk
CMSC, Building 10,                  | Phone: +44 (0) 20 8943 7090
National Physical Laboratory,       | Fax:   +44 (0) 20 8977 7091
Teddington, Middlesex, UK. TW11 OLW | WWW:   http://www.npl.co.uk

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About