summaryrefslogtreecommitdiff
path: root/lib/UNIVERSAL.pm
blob: c006547db087ef064c1c0e4f0de58d19caa55260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package UNIVERSAL;

require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(isa);

1;
__END__

=head1 NAME

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');

=head1 DESCRIPTION

C<UNIVERSAL> is the base class which all bless references will inherit from,
see L<perlobj>

C<UNIVERSAL> provides the following methods

=over 4

=item isa ( TYPE )

C<isa> returns I<true> if C<REF> is blessed into package C<TYPE>
or inherits from package C<TYPE>.

C<isa> can be called as either a static or object method call.

=item can ( METHOD )

C<can> checks if the object has a method called C<METHOD>. If it does
then a reference to the sub is returned. If it does not the I<undef>
is returned.

C<can> can be called as either a static or object method call.

=item VERSION ( [ REQUIRE ] )

C<VERSION> will return the value of the variable C<$VERSION> in the
package the object is blessed into. If C<REQUIRE> is given then
it will do a comparison and die if the package version is not
greater than or equal to C<REQUIRE>.

C<VERSION> can be called as either a static or object method call.

=back

C<UNIVERSAL> also optionally exports the following subroutines

=over 4

=item isa ( REF, TYPE )

C<isa> returns I<true> if the first argument is a reference and either
of the following statements is true.

=over 8

=item

C<REF> is a blessed reference and is blessed into package C<TYPE>
or inherits from package C<TYPE>

=item

C<REF> is a reference to a C<TYPE> of perl variable (er 'HASH')

=back

=back

=cut