line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UNIVERSAL::moniker; |
2
|
|
|
|
|
|
|
$UNIVERSAL::moniker::VERSION = '0.08'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
UNIVERSAL::moniker |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use UNIVERSAL::moniker; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Class names in Perl often don't sound great when spoken, or look good when |
15
|
|
|
|
|
|
|
written in prose. For this reason, we tend to say things like "customer" or |
16
|
|
|
|
|
|
|
"basket" when we are referring to C or |
17
|
|
|
|
|
|
|
C. We thought it would be nice if our classes knew what |
18
|
|
|
|
|
|
|
we would prefer to call them. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This module will add a C (and C) method to |
21
|
|
|
|
|
|
|
C, and so to every class or module. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 moniker |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$ob->moniker; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Returns the moniker for $ob. |
28
|
|
|
|
|
|
|
So, if $ob->isa("Big::Scary::Animal"), C will return "animal". |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 plural_moniker |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$ob->plural_moniker; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Returns the plural moniker for $ob. |
35
|
|
|
|
|
|
|
So, if $ob->isa("Cephalopod::Octopus"), C will return "octopuses". |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
(You need to install Lingua::EN::Inflect for this to work.) |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package UNIVERSAL; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub moniker { |
44
|
2
|
|
66
|
2
|
0
|
965
|
(ref( $_[0] ) || $_[0]) =~ /([^:]+)$/; |
45
|
2
|
|
|
|
|
13
|
return lc $1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub plural_moniker { |
49
|
0
|
|
|
0
|
0
|
|
CORE::require Lingua::EN::Inflect; |
50
|
0
|
|
|
|
|
|
return Lingua::EN::Inflect::PL($_[0]->moniker); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 AUTHORS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Marty Pauley , |
56
|
|
|
|
|
|
|
Tony Bowden , |
57
|
|
|
|
|
|
|
Elizabeth Mattijsen |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
(Yes, 3 authors for such a small module!) |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 COPYRIGHT |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Copyright (C) 2004 Kasei |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This program is free software; you can redistribute it under the same terms as |
66
|
|
|
|
|
|
|
Perl. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT |
69
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
70
|
|
|
|
|
|
|
FOR A PARTICULAR PURPOSE. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |