line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Lorem; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
4052
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
158
|
|
4
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
163
|
|
5
|
5
|
|
|
5
|
|
25
|
use vars qw($VERSION); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
2983
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = "0.33"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $lorem_singleton; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
9
|
|
|
9
|
1
|
7019
|
my $class = shift; |
13
|
9
|
|
100
|
|
|
68
|
$lorem_singleton ||= bless {},$class; |
14
|
9
|
|
|
|
|
22
|
return $lorem_singleton; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub generate_wordlist { |
18
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
19
|
3
|
|
|
|
|
381
|
return [ map { s/\W//; lc($_) }split(/\s+/, ) ]; |
|
747
|
|
|
|
|
1102
|
|
|
747
|
|
|
|
|
1455
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub wordlist { |
23
|
197
|
|
|
197
|
0
|
219
|
my $self = shift; |
24
|
197
|
|
66
|
|
|
414
|
return $self->{ wordlist } ||= $self->generate_wordlist(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub wordcount { |
28
|
197
|
|
|
197
|
0
|
236
|
my $self = shift; |
29
|
197
|
|
|
|
|
239
|
return scalar(@{$self->{ wordlist }}); |
|
197
|
|
|
|
|
571
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_word { |
33
|
197
|
|
|
197
|
0
|
251
|
my $self = shift; |
34
|
197
|
|
|
|
|
254
|
return $self->wordlist->[ int( rand( $self->wordcount ) ) ]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub words { |
38
|
35
|
|
|
35
|
1
|
52
|
my $self = shift; |
39
|
35
|
|
|
|
|
40
|
my $num = shift; |
40
|
35
|
|
|
|
|
44
|
my @words; |
41
|
35
|
|
|
|
|
70
|
push @words, $self->get_word() for (1..$num); |
42
|
35
|
100
|
|
|
|
133
|
return wantarray ? @words : join ' ', @words; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_sentence { |
46
|
33
|
|
|
33
|
0
|
44
|
my $self = shift; |
47
|
33
|
|
|
|
|
98
|
my $words = $self->words( 4 + int( rand( 6 ) ) ) . '.'; |
48
|
33
|
|
|
|
|
116
|
return ucfirst( $words ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub sentences { |
52
|
8
|
|
|
8
|
1
|
15
|
my $self = shift; |
53
|
8
|
|
|
|
|
11
|
my $num = shift; |
54
|
8
|
|
|
|
|
11
|
my @sentences; |
55
|
8
|
|
|
|
|
22
|
push @sentences, $self->get_sentence for (1..$num); |
56
|
8
|
100
|
|
|
|
32
|
return wantarray ? @sentences : join ' ', @sentences; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_paragraph { |
60
|
6
|
|
|
6
|
0
|
9
|
my $self = shift; |
61
|
6
|
|
|
|
|
51
|
my $paragraph = $self->sentences(3 + int( rand( 4 ) ) ); |
62
|
6
|
|
|
|
|
13
|
return $paragraph; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub paragraphs { |
66
|
2
|
|
|
2
|
1
|
8
|
my $self = shift; |
67
|
2
|
|
|
|
|
4
|
my $num = shift; |
68
|
2
|
|
|
|
|
4
|
my @paragraphs; |
69
|
2
|
|
|
|
|
6
|
push @paragraphs, $self->get_paragraph for (1..$num); |
70
|
2
|
100
|
|
|
|
34
|
return wantarray ? @paragraphs : join "\n\n", @paragraphs; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=pod |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Text::Lorem - Generate random Latin looking text |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SYNOPSIS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
use Text::Lorem; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $text = Text::Lorem->new(); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Generate a string of text with 5 words |
88
|
|
|
|
|
|
|
$words = $text->words(5); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Generate a list of 5 words |
91
|
|
|
|
|
|
|
@words = $text->words(5); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Generate a string of text with 2 sentences |
94
|
|
|
|
|
|
|
$sentences = $text->sentences(2); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Generate a list of 2 sentences |
97
|
|
|
|
|
|
|
@sentences = $text->sentences(2); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Generate a string of text with 3 paragraphs |
100
|
|
|
|
|
|
|
$paragraphs = $text->paragraphs(3); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Generate a list of 3 paragraphs |
103
|
|
|
|
|
|
|
@paragraphs = $text->paragraphs(3); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Often when developing a website or other application it's important to have placeholders for content. This module generates |
108
|
|
|
|
|
|
|
prescribed amounts of fake Latin text. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item C |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The default constructor, C takes no arguments and returns a Text::Lorem object. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 METHODS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
All methods below will return a string in scalar context or list in list context. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item C |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns INTEGER fake Latin words. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item C |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns INTEGER sentences in fake Latin. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item C |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns INTEGER paragraphs of fake Latin text. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 THANKS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Thanks to the guys who pushed me off the cliff called comfort and into the scary world of Perl: James Duncan, Leon Brocard. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Adeola Awoyemi (adeola@cpan.org) |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L and L |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright (c) 2003 by Adeola Awoyemi. |
155
|
|
|
|
|
|
|
This software is released under the same license as Perl itself. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
__DATA__ |