line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Lorem; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
3916
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
157
|
|
4
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
150
|
|
5
|
5
|
|
|
5
|
|
25
|
use vars qw($VERSION); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
2888
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = "0.32"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $lorem_singleton; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
9
|
|
|
9
|
1
|
7200
|
my $class = shift; |
13
|
9
|
|
100
|
|
|
67
|
$lorem_singleton ||= bless {},$class; |
14
|
9
|
|
|
|
|
22
|
return $lorem_singleton; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub generate_wordlist { |
18
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
19
|
3
|
|
|
|
|
381
|
return [ map { s/\W//; lc($_) }split(/\s+/, ) ]; |
|
747
|
|
|
|
|
1080
|
|
|
747
|
|
|
|
|
1410
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub wordlist { |
23
|
185
|
|
|
185
|
0
|
206
|
my $self = shift; |
24
|
185
|
|
66
|
|
|
386
|
return $self->{ wordlist } ||= $self->generate_wordlist(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub wordcount { |
28
|
185
|
|
|
185
|
0
|
213
|
my $self = shift; |
29
|
185
|
|
|
|
|
252
|
return scalar(@{$self->{ wordlist }}); |
|
185
|
|
|
|
|
572
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_word { |
33
|
185
|
|
|
185
|
0
|
246
|
my $self = shift; |
34
|
185
|
|
|
|
|
244
|
return $self->wordlist->[ int( rand( $self->wordcount ) ) ]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub words { |
38
|
30
|
|
|
30
|
1
|
43
|
my $self = shift; |
39
|
30
|
|
|
|
|
42
|
my $num = shift; |
40
|
30
|
|
|
|
|
35
|
my @words; |
41
|
30
|
|
|
|
|
64
|
push @words, $self->get_word() for (1..$num); |
42
|
30
|
100
|
|
|
|
134
|
return wantarray ? @words : join ' ', @words; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_sentence { |
46
|
28
|
|
|
28
|
0
|
40
|
my $self = shift; |
47
|
28
|
|
|
|
|
89
|
my $words = $self->words( 4 + int( rand( 6 ) ) ) . '.'; |
48
|
28
|
|
|
|
|
102
|
return ucfirst( $words ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub sentences { |
52
|
8
|
|
|
8
|
1
|
16
|
my $self = shift; |
53
|
8
|
|
|
|
|
11
|
my $num = shift; |
54
|
8
|
|
|
|
|
11
|
my @sentences; |
55
|
8
|
|
|
|
|
20
|
push @sentences, $self->get_sentence for (1..$num); |
56
|
8
|
100
|
|
|
|
33
|
return wantarray ? @sentences : join ' ', @sentences; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_paragraph { |
60
|
6
|
|
|
6
|
0
|
8
|
my $self = shift; |
61
|
6
|
|
|
|
|
64
|
my $paragraph = $self->sentences(3 + int( rand( 4 ) ) ); |
62
|
6
|
|
|
|
|
16
|
return $paragraph; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub paragraphs { |
66
|
2
|
|
|
2
|
1
|
8
|
my $self = shift; |
67
|
2
|
|
|
|
|
63
|
my $num = shift; |
68
|
2
|
|
|
|
|
4
|
my @paragraphs; |
69
|
2
|
|
|
|
|
9
|
push @paragraphs, $self->get_paragraph for (1..$num); |
70
|
2
|
100
|
|
|
|
30
|
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@fotango.com) |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L and L |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright 2003 Fotango Ltd. All rights reserved. L |
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__ |