home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / UNIVERSAL.pm < prev    next >
Encoding:
Perl POD Document  |  1999-12-28  |  2.2 KB  |  95 lines

  1. package UNIVERSAL;
  2.  
  3. require Exporter;
  4. *import = \&Exporter::import;
  5. @EXPORT_OK = qw(isa can);
  6.  
  7. 1;
  8. __END__
  9.  
  10. =head1 NAME
  11.  
  12. UNIVERSAL - base class for ALL classes (blessed references)
  13.  
  14. =head1 SYNOPSIS
  15.  
  16.     $io = $fd->isa("IO::Handle");
  17.     $sub = $obj->can('print');
  18.  
  19.     $yes = UNIVERSAL::isa($ref, "HASH");
  20.  
  21. =head1 DESCRIPTION
  22.  
  23. C<UNIVERSAL> is the base class which all bless references will inherit from,
  24. see L<perlobj>
  25.  
  26. C<UNIVERSAL> provides the following methods
  27.  
  28. =over 4
  29.  
  30. =item isa ( TYPE )
  31.  
  32. C<isa> returns I<true> if C<REF> is blessed into package C<TYPE>
  33. or inherits from package C<TYPE>.
  34.  
  35. C<isa> can be called as either a static or object method call.
  36.  
  37. =item can ( METHOD )
  38.  
  39. C<can> checks if the object has a method called C<METHOD>. If it does
  40. then a reference to the sub is returned. If it does not then I<undef>
  41. is returned.
  42.  
  43. C<can> can be called as either a static or object method call.
  44.  
  45. =item VERSION ( [ REQUIRE ] )
  46.  
  47. C<VERSION> will return the value of the variable C<$VERSION> in the
  48. package the object is blessed into. If C<REQUIRE> is given then
  49. it will do a comparison and die if the package version is not
  50. greater than or equal to C<REQUIRE>.
  51.  
  52. C<VERSION> can be called as either a static or object method call.
  53.  
  54. =back
  55.  
  56. The C<isa> and C<can> methods can also be called as subroutines
  57.  
  58. =over 4
  59.  
  60. =item UNIVERSAL::isa ( VAL, TYPE )
  61.  
  62. C<isa> returns I<true> if the first argument is a reference and either
  63. of the following statements is true.
  64.  
  65. =over 8
  66.  
  67. =item
  68.  
  69. C<VAL> is a blessed reference and is blessed into package C<TYPE>
  70. or inherits from package C<TYPE>
  71.  
  72. =item
  73.  
  74. C<VAL> is a reference to a C<TYPE> of perl variable (er 'HASH')
  75.  
  76. =back
  77.  
  78. =item UNIVERSAL::can ( VAL, METHOD )
  79.  
  80. If C<VAL> is a blessed reference which has a method called C<METHOD>,
  81. C<can> returns a reference to the subroutine.   If C<VAL> is not
  82. a blessed reference, or if it does not have a method C<METHOD>,
  83. I<undef> is returned.
  84.  
  85. =back
  86.  
  87. These subroutines should I<not> be imported via S<C<use UNIVERSAL qw(...)>>.
  88. If you want simple local access to them you can do
  89.  
  90.   *isa = \&UNIVERSAL::isa;
  91.  
  92. to import isa into your package.
  93.  
  94. =cut
  95.