Subject: | from_hash() insists on a non-empty HASH (+FIX) |
from_hash() uses Params::Util::_HASH, which insists the hash has at
least one key. That's annoying for when trying to use
Module::Math::Depends with dependency data returned by other existing
APIs. I.e.,:
$cpan = CPAN::Shell->expand('Module', $mod)->distribution;
$dep = Module::Math::Depends->from_hash($cpan->prereq_pm->{requires});
However, if the list of required modules is empty, the 'requires' is an
empty hash and that results in an error:
Did not provide a HASH reference at ./checkdep line 84
at .../lib/5.8.8/Module/Math/Depends.pm line 60
I could just special case my code to only call 'from_hash()' when the
hash isn't empty, but it's much better to allow empty hashes. This is a
trivial fix:
--- .snapshot/nightly.0/lib/5.8.8/Module/Math/Depends.pm
2006-09-24 22:29:23.000000000 -0400
+++ lib/5.8.8/Module/Math/Depends.pm 2007-05-14 14:00:30.311901000 -0400
@@ -22,3 +22,3 @@
use version ();
-use Params::Util qw{_CLASS _HASH _INSTANCE};
+use Params::Util qw{_CLASS _HASH0 _INSTANCE};
@@ -59,3 +59,3 @@
my $self = shift()->new;
- my $hash = _HASH(shift)
+ my $hash = _HASH0(shift)
or Carp::croak("Did not provide a HASH reference");