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

[perl #81078] [PATCH] UNIVERSAL(3p) manual: recommend plain ref() rather than Scalar::Util

Thread Next
From:
Ingo Schwarze
Date:
December 21, 2010 13:10
Subject:
[perl #81078] [PATCH] UNIVERSAL(3p) manual: recommend plain ref() rather than Scalar::Util
Message ID:
rt-3.6.HEAD-5425-1292933606-1215.81078-75-0@perl.org
# New Ticket Created by  Ingo Schwarze 
# Please include the string:  [perl #81078]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81078 >


Hi,

since Scalar::Util::reftype() seems obsolete, i suggest that
the UNIVERSAL(3p) manual ought to recommend using the builtin
function ref() instead.

Yours,
  Ingo

-- 
Ingo Schwarze <ischwarze@astaro.com> | Software Engineer
Astaro GmbH & Co. KG | www.astaro.com | 76227 Karlsruhe | Germany

---
 lib/UNIVERSAL.pm |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm
index 8960462..d3d843a 100644
--- a/lib/UNIVERSAL.pm
+++ b/lib/UNIVERSAL.pm
@@ -201,11 +201,9 @@ a function to determine the type of a reference:
   $yes = isa "Foo", "Bar";
 
 The problem is that this code will I<never> call an overridden C<isa> method in
-any class.  Instead, use C<reftype> from L<Scalar::Util> for the first case:
+any class.  Instead, use the builtin function C<ref> for the first case:
 
-  use Scalar::Util 'reftype';
-
-  $yes = reftype( $h ) eq "HASH";
+  $yes = ref($h) eq "HASH";
 
 and the method form of C<isa> for the second:
 
-- 
1.7.1


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