Hi guys
We've encountered a warning like "Can't call method "isa" on unblessed reference" at
Hash/Merge.pm line 100
as I dug, the problem is we call _merge_hashes( $_[0], $_[1] ) when specify_behavior.
well surely, since $_[0] is hashref, the warning pops out.
_get_obj calls $_[0]->isa when ref $_[0] is not empty, though it's safe to call in an eval
block, maybe we can get rid of eval by more testing before calling $_[0]->isa?
I suggest use blessed in Scalar::Util or just skip the SCALAR|ARRAY|HASH.
the patch for the latter one is attached.
best wishes
sunnavy

Same problem. This prevents using Hash::Merge. For some reason it seems
that the eval block dies on this line. If I run a simple example, this
works. But when this is a part of bigger script, the problem appears and
it must be my script. Unfortunately I cannot identify the root problem.
Also, should the OR be AND on that line? I could also guess that the
eval part is unnecessary? But at least using AND instead of OR prevents
calling the eval block and seems to work for me.
sub _get_obj {
if ( my $type = ref $_[0] ) {
return shift() if $type eq __PACKAGE__ || eval {
$_[0]->isa(__PACKAGE__) };
}

Same problem. This prevents using Hash::Merge. For some reason it seems
that the eval block dies on this line. If I run a simple example, this
works. But when this is a part of bigger script, the problem appears and
it must be my script. Unfortunately I cannot identify the root problem.
Also, should the OR be AND on that line? I could also guess that the
eval part is unnecessary? But at least using AND instead of OR prevents
calling the eval block and seems to work for me.
sub _get_obj {
if ( my $type = ref $_[0] ) {
return shift() if $type eq __PACKAGE__ || eval {
$_[0]->isa(__PACKAGE__) };
}

Hi,
This also causes issues with a __DIE__ handler as the eval generates errors, it ends up in the handler.
The code should use Scalar::Util::blessed to test whether it's an object or not:
diff Merge.pm.original Merge.pm
5a6
Show quoted text

This has been patched upstream with commit c01a97cdb9930ca81a276d3e6c216f05d6adac08.
Use Scalar::Util::blessed to test whether the arg is a reference
or not, before calling "isa" on it. Blindly calling "isa" and
using eval to ignore the resulting error still triggers DIE
handlers when it does not need to.
Submitted by Larry Leszczynski