line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Lorem; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
4193
|
use strict; |
|
5
|
|
|
|
|
53
|
|
|
5
|
|
|
|
|
169
|
|
4
|
5
|
|
|
5
|
|
58
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
186
|
|
5
|
5
|
|
|
5
|
|
26
|
use vars qw($VERSION); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
3114
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = "0.34"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $lorem_singleton; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
9
|
|
|
9
|
1
|
7588
|
my $class = shift; |
13
|
9
|
|
100
|
|
|
68
|
$lorem_singleton ||= bless {},$class; |
14
|
9
|
|
|
|
|
25
|
return $lorem_singleton; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub generate_wordlist { |
18
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
19
|
3
|
|
|
|
|
397
|
return [ map { s/\W//; lc($_) }split(/\s+/, ) ]; |
|
747
|
|
|
|
|
1128
|
|
|
747
|
|
|
|
|
1562
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub wordlist { |
23
|
237
|
|
|
237
|
0
|
303
|
my $self = shift; |
24
|
237
|
|
66
|
|
|
496
|
return $self->{ wordlist } ||= $self->generate_wordlist(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub wordcount { |
28
|
237
|
|
|
237
|
0
|
320
|
my $self = shift; |
29
|
237
|
|
|
|
|
279
|
return scalar(@{$self->{ wordlist }}); |
|
237
|
|
|
|
|
732
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_word { |
33
|
237
|
|
|
237
|
0
|
369
|
my $self = shift; |
34
|
237
|
|
|
|
|
332
|
return $self->wordlist->[ int( rand( $self->wordcount ) ) ]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub words { |
38
|
35
|
|
|
35
|
1
|
55
|
my $self = shift; |
39
|
35
|
|
|
|
|
43
|
my $num = shift; |
40
|
35
|
|
|
|
|
39
|
my @words; |
41
|
35
|
|
|
|
|
77
|
push @words, $self->get_word() for (1..$num); |
42
|
35
|
100
|
|
|
|
148
|
return wantarray ? @words : join ' ', @words; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_sentence { |
46
|
33
|
|
|
33
|
0
|
48
|
my $self = shift; |
47
|
33
|
|
|
|
|
96
|
my $words = $self->words( 4 + int( rand( 6 ) ) ) . '.'; |
48
|
33
|
|
|
|
|
127
|
return ucfirst( $words ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub sentences { |
52
|
8
|
|
|
8
|
1
|
18
|
my $self = shift; |
53
|
8
|
|
|
|
|
12
|
my $num = shift; |
54
|
8
|
|
|
|
|
9
|
my @sentences; |
55
|
8
|
|
|
|
|
24
|
push @sentences, $self->get_sentence for (1..$num); |
56
|
8
|
100
|
|
|
|
38
|
return wantarray ? @sentences : join ' ', @sentences; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_paragraph { |
60
|
6
|
|
|
6
|
0
|
10
|
my $self = shift; |
61
|
6
|
|
|
|
|
62
|
my $paragraph = $self->sentences(3 + int( rand( 4 ) ) ); |
62
|
6
|
|
|
|
|
17
|
return $paragraph; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub paragraphs { |
66
|
2
|
|
|
2
|
1
|
10
|
my $self = shift; |
67
|
2
|
|
|
|
|
4
|
my $num = shift; |
68
|
2
|
|
|
|
|
3
|
my @paragraphs; |
69
|
2
|
|
|
|
|
10
|
push @paragraphs, $self->get_paragraph for (1..$num); |
70
|
2
|
100
|
|
|
|
39
|
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__ |