summaryrefslogtreecommitdiff
path: root/lib/UNIVERSAL.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/UNIVERSAL.pm')
-rw-r--r--lib/UNIVERSAL.pm23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm
index 6d832c4bea..dc02423029 100644
--- a/lib/UNIVERSAL.pm
+++ b/lib/UNIVERSAL.pm
@@ -1,7 +1,10 @@
package UNIVERSAL;
+# UNIVERSAL should not contain any extra subs/methods beyond those
+# that it exists to define. The use of Exporter below is a historical
+# accident that should be fixed sometime.
require Exporter;
-@ISA = qw(Exporter);
+*import = \&Exporter::import;
@EXPORT_OK = qw(isa can);
1;
@@ -13,12 +16,11 @@ UNIVERSAL - base class for ALL classes (blessed references)
=head1 SYNOPSIS
- use UNIVERSAL qw(isa);
-
- $yes = isa($ref, "HASH");
$io = $fd->isa("IO::Handle");
$sub = $obj->can('print');
+ $yes = UNIVERSAL::isa($ref, "HASH");
+
=head1 DESCRIPTION
C<UNIVERSAL> is the base class which all bless references will inherit from,
@@ -54,11 +56,11 @@ C<VERSION> can be called as either a static or object method call.
=back
-C<UNIVERSAL> also optionally exports the following subroutines
+The C<isa> and C<can> methods can also be called as subroutines
=over 4
-=item isa ( VAL, TYPE )
+=item UNIVERSAL::isa ( VAL, TYPE )
C<isa> returns I<true> if the first argument is a reference and either
of the following statements is true.
@@ -76,7 +78,7 @@ C<VAL> is a reference to a C<TYPE> of perl variable (er 'HASH')
=back
-=item can ( VAL, METHOD )
+=item UNIVERSAL::can ( VAL, METHOD )
If C<VAL> is a blessed reference which has a method called C<METHOD>,
C<can> returns a reference to the subroutine. If C<VAL> is not
@@ -85,4 +87,11 @@ I<undef> is returned.
=back
+These subroutines should I<not> be imported via S<C<use UNIVERSAL qw(...)>>.
+If you want simple local access to them you can do
+
+ *isa = \&UNIVERSAL::isa;
+
+to import isa into your package.
+
=cut