From: Rafael Garcia-Suarez Date: Sat, 6 Dec 2003 19:58:51 +0000 (+0000) Subject: Remove the "Can't provide tied hash usage" error from perldiag. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=085bcbb1d33da8a158e1316d85fae9d242baf2d0;p=p5sagit%2Fp5-mst-13.2.git Remove the "Can't provide tied hash usage" error from perldiag. Mention the new tied hash SCALAR method in perldelta. p4raw-id: //depot/perl@21857 --- diff --git a/pod/perldelta.pod b/pod/perldelta.pod index f8b5dea..9ebb2ed 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -216,6 +216,22 @@ contains a package variable named C<$NEGATIVE_INDICES> which is set to a true value, negative values will be passed to C, C, C, and C unchanged. +=head2 Tied hashes in scalar context + +As of perl 5.8.2, tied hashes did not return anything useful in scalar +context, for example when used as boolean tests: + + if (%tied_hash) { ... } + +The old nonsensical behaviour was always to return false, +regardless of whether the hash is empty or has elements. + +There is now an interface for the implementors of tied hashes to implement +the behaviour of a hash in scalar context, via the SCALAR method (see +L). Without a SCALAR method, perl will try to guess whether +the hash is empty, by testing if it's inside an iteration (in this case +it can't be empty) or by calling FIRSTKEY. + =head2 local ${$x} The syntaxes @@ -861,19 +877,6 @@ common Perl platforms (Unix and Unix-like, Microsoft platforms, and VMS) have large enough testing and expert population that they are doing well. -=head2 Tied hashes in scalar context - -Tied hashes do not currently return anything useful in scalar context, -for example when used as boolean tests: - - if (%tied_hash) { ... } - -The current nonsensical behaviour is always to return false, -regardless of whether the hash is empty or has elements. - -The root cause is that there is no interface for the implementors of -tied hashes to implement the behaviour of a hash in scalar context. - =head2 Net::Ping 450_service and 510_ping_udp failures The subtests 9 and 18 of lib/Net/Ping/t/450_service.t, and the diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 2b98439..2fb8615 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -911,14 +911,6 @@ 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