summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorYitzchak Scott-Thoennes <sthoenna@efn.org>2003-05-07 08:27:07 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2003-05-08 18:12:46 +0000
commit126c71c82576d5dc652db25ca9e3f8e18442c4fd (patch)
treee2790a78faaa94be96e8fcce8035cddddae1602e /pod
parent86e5a81e88dbe10bf1c195d6ca6fefab8bfafc17 (diff)
downloadperl-126c71c82576d5dc652db25ca9e3f8e18442c4fd.tar.gz
Re: [perl #17718] %tiedhash in bool context doesn't check if hash is empty
Message-ID: <7gYu+gzkgaFU092yn@efn.org> p4raw-id: //depot/perl@19452
Diffstat (limited to 'pod')
-rw-r--r--pod/perldata.pod4
-rw-r--r--pod/perldiag.pod8
-rw-r--r--pod/perltie.pod8
3 files changed, 19 insertions, 1 deletions
diff --git a/pod/perldata.pod b/pod/perldata.pod
index 572058924f..c58d41974a 100644
--- a/pod/perldata.pod
+++ b/pod/perldata.pod
@@ -257,7 +257,9 @@ Perl's internal hashing algorithm is performing poorly on your data
set. For example, you stick 10,000 things in a hash, but evaluating
%HASH in scalar context reveals C<"1/16">, which means only one out
of sixteen buckets has been touched, and presumably contains all
-10,000 of your items. This isn't supposed to happen.
+10,000 of your items. This isn't supposed to happen. If a tied hash
+is evaluated in scalar context, a fatal error will result, since this
+bucket usage information is currently not available for tied hashes.
You can preallocate space for a hash by assigning to the keys() function.
This rounds up the allocated buckets to the next power of two:
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index b6558ec998..ad5841ca34 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -912,6 +912,14 @@ for stdout.
(F) The script you specified can't be opened for the indicated reason.
+=item Can't provide tied hash usage; use keys(%hash) to test if empty
+
+(F) When a hash is evaluated in scalar context, bucket usage is
+returned if the hash is populated, and false is returned if the hash
+is empty. Bucket usage is not currently available for tied hashes.
+To test if a hash is empty or populated, use keys(%hash) in scalar
+context instead.
+
=item Can't read CRTL environ
(S) A warning peculiar to VMS. Perl tried to read an element of %ENV
diff --git a/pod/perltie.pod b/pod/perltie.pod
index 05b79730c3..3665f0420e 100644
--- a/pod/perltie.pod
+++ b/pod/perltie.pod
@@ -1076,6 +1076,14 @@ source code to MLDBM.
Tied filehandles are still incomplete. sysopen(), truncate(),
flock(), fcntl(), stat() and -X can't currently be trapped.
+The bucket usage information provided by C<scalar(%hash)> is not
+available. If C<%hash> is tied, this will currently result in a
+fatal error.
+
+Counting the number of entries in a hash via C<scalar(keys(%hash))> or
+C<scalar(values(%hash)>) is inefficient since it needs to iterate
+through all the entries with FIRSTKEY/NEXTKEY.
+
=head1 AUTHOR
Tom Christiansen