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

[perl #134452] ref should trigger warnings and doc needs work

Thread Next
From:
Dan Book via RT
Date:
September 27, 2019 22:32
Subject:
[perl #134452] ref should trigger warnings and doc needs work
Message ID:
rt-4.0.24-30607-1569623554-1403.134452-15-0@perl.org
On Thu, 26 Sep 2019 18:20:45 -0700, rirans@comcast.net wrote:
> $ perldoc -f ref
> ...
>     If the referenced object has been blessed into a package, then
>     that package name is returned instead. But don't use that, as it's
>     now considered "bad practice". For one reason, an object could be
>     using a class called "Regexp" or "IO", or even "HASH". Also, "ref"
>     doesn't take into account subclasses, like "isa" does.
> 
> Instead, use "blessed" (in the Scalar::Util module) for boolean
> checks, "isa" for specific class checks and "reftype" (also from
> Scalar::Util) for type checks. (See perlobj for details and a
> "blessed"/"isa" example.)

Note this documentation is out of date; the latest version can be viewed at https://perldoc.pl/functions/ref .

-Dan

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=134452

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