develooper Front page | perl.perl5.porters | Postings from September 2010

Hash::Util::lock_hash_recurse throws warnings

Thread Next
From:
Chas. Owens
Date:
September 16, 2010 07:36
Subject:
Hash::Util::lock_hash_recurse throws warnings
Message ID:
AANLkTim16Z9gNtbrhr1f=djf=jR=p+V1GeZ+yFa7y0R_@mail.gmail.com
For an example of the bug see
http://stackoverflow.com/questions/3727619/how-do-i-use-lock-hash-recurse-in-perl/3727667#3727667

Here is a patch that fixes the warnings.  I did not include a test
because I don't know the canonical way to test for warnings (I know
how I do it, and it isn't pretty).

diff --git a/ext/Hash-Util/lib/Hash/Util.pm b/ext/Hash-Util/lib/Hash/Util.pm
index 95da7d9..158a70e 100644
--- a/ext/Hash-Util/lib/Hash/Util.pm
+++ b/ext/Hash-Util/lib/Hash/Util.pm
@@ -321,7 +321,8 @@ sub lock_hashref_recurse {

     lock_ref_keys($hash);
     foreach my $value (values %$hash) {
-        if (reftype($value) eq 'HASH') {
+        my $type = reftype($value);
+        if (defined $type and $type eq 'HASH') {
             lock_hashref_recurse($value);
         }
         Internals::SvREADONLY($value,1);
diff --git a/pod/perl5135delta.pod b/pod/perl5135delta.pod
index c1b5bc7..ccd3645 100644
--- a/pod/perl5135delta.pod
+++ b/pod/perl5135delta.pod
@@ -139,6 +139,16 @@ XXX Description of the change here

 =back

+=head3 L<perlport>
+
+=over 4
+
+=item *
+
+fixed typo
+
+=back
+
 =head1 Diagnostics

 The following additions or changes have been made to diagnostic output,


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About