X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FUNIVERSAL.pm;h=f2f1fe9e7adeba41686210e68fadf3ac6b9a46c9;hb=11d7f64f86584fefbeb7beb3792b3ccd34a45058;hp=6d832c4bea283abd8212c2151971c95d1ce05289;hpb=a66bc3b0c7b47b1405c3f62393e8f35e9a4bbdb8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm index 6d832c4..f2f1fe9 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,29 +56,33 @@ 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. +C returns I if one of the following statements is true. =over 8 -=item +=item * + +C is a reference blessed into either package C or a package +which inherits from package C. + +=item * -C is a blessed reference and is blessed into package C -or inherits from package C +C is a reference to a C of Perl variable (e.g. 'HASH'). -=item +=item * -C is a reference to a C of perl variable (er 'HASH') +C is the name of a package that inherits from (or is itself) +package C. =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 +91,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