From f75437398a7a18f7852b0151f7cb808dbeb06d0a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 11 Nov 2010 20:09:58 -0600 Subject: preserve existing behavior here i guess --- lib/Package/Stash.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/Package/Stash.pm') diff --git a/lib/Package/Stash.pm b/lib/Package/Stash.pm index 88f921e..132f687 100644 --- a/lib/Package/Stash.pm +++ b/lib/Package/Stash.pm @@ -204,7 +204,16 @@ sub has_package_symbol { my $entry_ref = \$namespace->{$name}; if (reftype($entry_ref) eq 'GLOB') { - return defined *{$entry_ref}{$type}; + # XXX: assigning to any typeglob slot also initializes the SCALAR slot, + # and saying that an undef scalar variable doesn't exist is probably + # vaguely less surprising than a scalar variable popping into existence + # without anyone defining it + if ($type eq 'SCALAR') { + return defined ${ *{$entry_ref}{$type} }; + } + else { + return defined *{$entry_ref}{$type}; + } } else { # a symbol table entry can be -1 (stub), string (stub with prototype), -- cgit v1.2.3-54-g00ecf