Subject: | Tie::CPHash suggested changes |
Date: | Fri, 3 Mar 2006 13:17:28 -0800 |
To: | bug-Tie-CPHash [...] rt.cpan.org |
From: | Yitzchak Scott-Thoennes <sthoenna [...] efn.org> |
As of 5.8.3, perl's hash tying mechanism was enhanced to make
if (%tiedhash) {
work. Most of the time, perl can correctly guess if the hash is
empty or not, but to cover all the cases, it's recommended that
hash tying classes implement a SCALAR method. Also, I see that
CPAN has your email address as having changed.
--- Tie-CPHash-1.001/Changes.orig 1998-10-25 15:15:24.000000000 -0800
+++ Tie-CPHash-1.001/Changes 2006-02-05 20:37:04.109273600 -0800
@@ -1,5 +1,8 @@
Revision history for Perl extension Tie::CPHash.
+1.002 Feb 05 2006
+ - add SCALAR method, update email address
+
1.001 Oct 25 1998
- updated my email address
--- Tie-CPHash-1.001/CPHash.pm.orig 1998-10-25 15:13:41.000000000 -0800
+++ Tie-CPHash-1.001/CPHash.pm 2006-02-05 20:36:17.422140800 -0800
@@ -1,11 +1,11 @@
#---------------------------------------------------------------------
package Tie::CPHash;
#
-# Copyright 1997 Christopher J. Madsen
+# Copyright 1997, 2006 Christopher J. Madsen
#
-# Author: Christopher J. Madsen <chris_madsen@geocities.com>
+# Author: Christopher J. Madsen <cjm@pobox.com>
# Created: 08 Nov 1997
-# Version: 1.001 (25-Oct-1998)
+# Version: 1.002 (05-Feb-2006)
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
@@ -30,7 +30,7 @@
BEGIN
{
# Convert RCS revision number to d.ddd format:
- $VERSION = sprintf('%d.%03d', '1.001 ' =~ /(\d+)\.(\d+)/);
+ $VERSION = sprintf('%d.%03d', '1.002 ' =~ /(\d+)\.(\d+)/);
} # end BEGIN
#=====================================================================
@@ -113,6 +113,16 @@
%{$_[0]} = ();
} # end CLEAR
+#---------------------------------------------------------------------
+# SCALAR this
+# Returns bucket usage information for the tied hash *this*
+# or 0 if it is empty.
+
+sub SCALAR
+{
+ scalar %{$_[0]};
+} # end SCALAR
+
#=====================================================================
# Other Methods:
#---------------------------------------------------------------------
@@ -180,7 +190,7 @@
=head1 AUTHOR
-Christopher J. Madsen E<lt>F<chris_madsen@geocities.com>E<gt>
+Christopher J. Madsen E<lt>F<cjm@pobox.com>E<gt>
=cut