summaryrefslogtreecommitdiff
path: root/systems/texlive/tlnet/tlpkg/tlperl/lib/UNIVERSAL.pm
diff options
context:
space:
mode:
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/UNIVERSAL.pm')
-rw-r--r--systems/texlive/tlnet/tlpkg/tlperl/lib/UNIVERSAL.pm27
1 files changed, 15 insertions, 12 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/UNIVERSAL.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/UNIVERSAL.pm
index 12800fb54c..96ecfe6e43 100644
--- a/systems/texlive/tlnet/tlpkg/tlperl/lib/UNIVERSAL.pm
+++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/UNIVERSAL.pm
@@ -1,6 +1,6 @@
package UNIVERSAL;
-our $VERSION = '1.13';
+our $VERSION = '1.15';
# UNIVERSAL should not contain any extra subs/methods beyond those
# that it exists to define. The existence of import() below is a historical
@@ -24,21 +24,21 @@ UNIVERSAL - base class for ALL classes (blessed references)
=head1 SYNOPSIS
- $is_io = $fd->isa("IO::Handle");
- $is_io = Class->isa("IO::Handle");
+ my $obj_is_io = $fd->isa("IO::Handle");
+ my $cls_is_io = Class->isa("IO::Handle");
- $does_log = $obj->DOES("Logger");
- $does_log = Class->DOES("Logger");
+ my $obj_does_log = $obj->DOES("Logger");
+ my $cls_does_log = Class->DOES("Logger");
- $sub = $obj->can("print");
- $sub = Class->can("print");
+ my $obj_sub = $obj->can("print");
+ my $cls_sub = Class->can("print");
- $sub = eval { $ref->can("fandango") };
- $ver = $obj->VERSION;
+ my $eval_sub = eval { $ref->can("fandango") };
+ my $ver = $obj->VERSION;
# but never do this!
- $is_io = UNIVERSAL::isa($fd, "IO::Handle");
- $sub = UNIVERSAL::can($obj, "print");
+ my $is_io = UNIVERSAL::isa($fd, "IO::Handle");
+ my $sub = UNIVERSAL::can($obj, "print");
=head1 DESCRIPTION
@@ -87,7 +87,10 @@ inherits from (or is itself) the name of the package C<TYPE> or
inherits from package C<TYPE>.
If you're not sure what you have (the C<VAL> case), wrap the method call in an
-C<eval> block to catch the exception if C<VAL> is undefined.
+C<eval> block to catch the exception if C<VAL> is undefined or an unblessed
+reference. The L<C<isa> operator|perlop/"Class Instance Operator"> is an
+alternative that simply returns false in this case, so the C<eval> is not
+needed.
If you want to be sure that you're calling C<isa> as a method, not a class,
check the invocand with C<blessed> from L<Scalar::Util> first: