X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FUNIVERSAL.pm;h=dc02423029edddd61ef853b75833ec4eb27b5e7c;hb=3937c24e3f4ed26beafd7a2fbe3a20466bfc2b2d;hp=6d832c4bea283abd8212c2151971c95d1ce05289;hpb=a66bc3b0c7b47b1405c3f62393e8f35e9a4bbdb8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm index 6d832c4..dc02423 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 is the base class which all bless references will inherit from, @@ -54,11 +56,11 @@ C can be called as either a static or object method call. =back -C also optionally exports the following subroutines +The C and C methods can also be called as subroutines =over 4 -=item isa ( VAL, TYPE ) +=item UNIVERSAL::isa ( VAL, TYPE ) C returns I if the first argument is a reference and either of the following statements is true. @@ -76,7 +78,7 @@ C is a reference to a C of perl variable (er 'HASH') =back -=item can ( VAL, METHOD ) +=item UNIVERSAL::can ( VAL, METHOD ) If C is a blessed reference which has a method called C, C returns a reference to the subroutine. If C is not @@ -85,4 +87,11 @@ I is returned. =back +These subroutines should I be imported via S>. +If you want simple local access to them you can do + + *isa = \&UNIVERSAL::isa; + +to import isa into your package. + =cut