From: John Hughes Date: Wed, 29 Jan 1997 22:16:21 +0000 (+1200) Subject: In Symbol::gensym, don't make glob fake by copying it X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6adf1df6c95069d09f9538d7c0eab6948cc799c9;p=p5sagit%2Fp5-mst-13.2.git In Symbol::gensym, don't make glob fake by copying it --- diff --git a/lib/Symbol.pm b/lib/Symbol.pm index 75d1dfb..e40ae7b 100644 --- a/lib/Symbol.pm +++ b/lib/Symbol.pm @@ -58,10 +58,16 @@ my $genseq = 0; my %global = map {$_ => 1} qw(ARGV ARGVOUT ENV INC SIG STDERR STDIN STDOUT); +# +# Note that we never _copy_ the glob; we just make a ref to it. +# If we did copy it, then SVf_FAKE would be set on the copy, and +# glob-specific behaviors (e.g. C<*$ref = \&func>) wouldn't work. +# sub gensym () { my $name = "GEN" . $genseq++; - local *{$genpkg . $name}; - \delete ${$genpkg}{$name}; + my $ref = \*{$genpkg . $name}; + delete $$genpkg{$name}; + $ref; } sub ungensym ($) {}