[Bps-public-commit] Symbol-Global-Name branch, master, updated. 0.02-4-ge3d5e22
Alex Vandiver
alexmv at bestpractical.com
Wed Jul 3 19:12:04 EDT 2013
The branch, master has been updated
via e3d5e22a0de36c2333712cd8f62bc8b8a7b77d4b (commit)
from 2fd1fee3956b0b67becc3752bd365459b17ff230 (commit)
Summary of changes:
lib/Symbol/Global/Name.pm | 1 +
1 file changed, 1 insertion(+)
- Log -----------------------------------------------------------------
commit e3d5e22a0de36c2333712cd8f62bc8b8a7b77d4b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jun 18 23:23:09 2013 +0800
compare ref type first to make sure $entry_ref is not weirdly overloaded
one snippet:
use Math::BigInt;
no strict 'refs';
# $round_mode = bless( do{\(my $o = 'even')}, 'Math::BigInt' );
my $round_mode = *{'Math::BigInt::round_mode'}{SCALAR};
print 'ok' if $round_mode;
Because Math::BigInt overloads "bool" operation, the "if $round_mode"
dies with message "Not a HASH reference". Bullet-proof against this by
ensuring that the type of the $entry_ref that we get back is the type of
the object we are looking for.
This was often less of a problem on perl < 5.18.0, when hash's keys()
behavior changed:
Hash randomization
The seed used by Perl's hash function is now random. This means that the
order which keys/values will be returned from functions like "keys()",
"values()", and "each()" will differ from run to run.
i.e. previously it was predictable if Math::BigInt::round_mode was
reached; on 5.18.0 and later it is not.
diff --git a/lib/Symbol/Global/Name.pm b/lib/Symbol/Global/Name.pm
index a094e93..c741413 100644
--- a/lib/Symbol/Global/Name.pm
+++ b/lib/Symbol/Global/Name.pm
@@ -107,6 +107,7 @@ sub _find {
$ref_type = 'SCALAR' if $ref_type eq 'REF';
my $entry_ref = *{$entry}{ $ref_type };
+ next if ref $entry_ref && ref $entry_ref ne ref $ref;
next unless $entry_ref;
# if references are equal then we've found
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list