| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Chicken::Ipsum; |
|
2
|
3
|
|
|
3
|
|
2003
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
91
|
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
151
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Chicken::Ipsum - Generate random chicken noises |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Chicken::Ipsum; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $ci = Chicken::Ipsum->new(); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Generate a string of text with 5 words |
|
18
|
|
|
|
|
|
|
$words = $ci->words(5); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Generate a list of 5 words |
|
21
|
|
|
|
|
|
|
@words = $ci->words(5); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Generate a string of text with 2 sentences |
|
24
|
|
|
|
|
|
|
$sentences = $ci->sentences(2); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Generate a list of 2 sentences |
|
27
|
|
|
|
|
|
|
@sentences = $ci->sentences(2); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Generate a string of text with 3 paragraphs |
|
30
|
|
|
|
|
|
|
$paragraphs = $ci->paragraphs(3); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Generate a list of 3 paragraphs |
|
33
|
|
|
|
|
|
|
@paragraphs = $ci->paragraphs(3); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Often when developing a website or other application, it's important to have |
|
38
|
|
|
|
|
|
|
placeholders for content. This module generates prescribed amounts of clucking, |
|
39
|
|
|
|
|
|
|
cawing and other chicken-y noises. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
3
|
|
24
|
use List::Util qw/ sample /; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
415
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
397
|
use constant WORDS => [qw/ |
|
46
|
|
|
|
|
|
|
puk |
|
47
|
|
|
|
|
|
|
pukaaak |
|
48
|
|
|
|
|
|
|
cluck |
|
49
|
|
|
|
|
|
|
cluck-cluck-cluck |
|
50
|
|
|
|
|
|
|
cluckity |
|
51
|
|
|
|
|
|
|
bwak |
|
52
|
|
|
|
|
|
|
waaak |
|
53
|
|
|
|
|
|
|
bok |
|
54
|
|
|
|
|
|
|
bwok |
|
55
|
|
|
|
|
|
|
cluck-a-buh-gawk |
|
56
|
|
|
|
|
|
|
cock-a-doodle-doo |
|
57
|
|
|
|
|
|
|
bwwwaaaaaaaaaak |
|
58
|
|
|
|
|
|
|
gobble-gobble |
|
59
|
|
|
|
|
|
|
honk |
|
60
|
3
|
|
|
3
|
|
33
|
/]; |
|
|
3
|
|
|
|
|
5
|
|
|
61
|
3
|
|
|
|
|
180
|
use constant PUNCTUATIONS => [qw/ |
|
62
|
|
|
|
|
|
|
. |
|
63
|
|
|
|
|
|
|
... |
|
64
|
|
|
|
|
|
|
! |
|
65
|
|
|
|
|
|
|
? |
|
66
|
3
|
|
|
3
|
|
21
|
/]; |
|
|
3
|
|
|
|
|
6
|
|
|
67
|
3
|
|
|
3
|
|
18
|
use constant MIN_SENTENCE_WORDS => 4; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
188
|
|
|
68
|
3
|
|
|
3
|
|
19
|
use constant MAX_SENTENCE_WORDS => 10; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
180
|
|
|
69
|
3
|
|
|
3
|
|
28
|
use constant MIN_PARAGRAPH_SENTENCES => 3; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
183
|
|
|
70
|
3
|
|
|
3
|
|
18
|
use constant MAX_PARAGRAPH_SENTENCES => 7; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1444
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 C |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The default constructor, C takes no arguments and returns a |
|
77
|
|
|
|
|
|
|
Chicken::Ipsum object. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub new { |
|
82
|
3
|
|
|
3
|
1
|
1714
|
my ($class) = @_; |
|
83
|
3
|
|
|
|
|
10
|
return bless { |
|
84
|
|
|
|
|
|
|
}, $class; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 METHODS |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
All methods below will return a string in scalar context or list in list context. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 C |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns INTEGER Chicken words. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub words { |
|
98
|
49
|
|
|
49
|
1
|
83
|
my ($self, $num) = @_; |
|
99
|
49
|
|
|
|
|
94
|
my @words = sample $num, @{+WORDS}; |
|
|
49
|
|
|
|
|
233
|
|
|
100
|
49
|
100
|
|
|
|
243
|
return wantarray ? @words : "@words"; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 C |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns INTEGER sentences in Chicken. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub sentences { |
|
110
|
14
|
|
|
14
|
1
|
35
|
my ($self, $num) = @_; |
|
111
|
14
|
|
|
|
|
23
|
my @sentences; |
|
112
|
|
|
|
|
|
|
# Sentences remaining "goes to" 0, LOL. |
|
113
|
|
|
|
|
|
|
# (See https://stackoverflow.com/q/1642028/237955) |
|
114
|
14
|
|
|
|
|
30
|
while ($num --> 0) { |
|
115
|
45
|
|
|
|
|
85
|
push @sentences, $self->_get_sentence(); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
14
|
100
|
|
|
|
78
|
return wantarray ? @sentences : "@sentences"; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 C |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns INTEGER paragraphs of Chicken text. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub paragraphs { |
|
127
|
5
|
|
|
5
|
1
|
13
|
my ($self, $num) = @_; |
|
128
|
5
|
|
|
|
|
9
|
my @paragraphs; |
|
129
|
5
|
|
|
|
|
14
|
while ($num --> 0) { |
|
130
|
9
|
|
|
|
|
18
|
push @paragraphs, $self->_get_paragraph; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
5
|
100
|
|
|
|
38
|
return wantarray ? @paragraphs : join "\n\n", @paragraphs; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub _get_paragraph { |
|
136
|
9
|
|
|
9
|
|
12
|
my $self = shift; |
|
137
|
9
|
|
|
|
|
60
|
my $num = MIN_PARAGRAPH_SENTENCES + int rand MAX_PARAGRAPH_SENTENCES - MIN_PARAGRAPH_SENTENCES; |
|
138
|
9
|
|
|
|
|
22
|
my $paragraph = $self->sentences($num); |
|
139
|
9
|
|
|
|
|
25
|
return $paragraph; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub _get_punctuation { |
|
143
|
45
|
|
|
45
|
|
54
|
return sample 1, @{+PUNCTUATIONS}; |
|
|
45
|
|
|
|
|
203
|
|
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub _get_sentence { |
|
147
|
45
|
|
|
45
|
|
54
|
my $self = shift; |
|
148
|
45
|
|
|
|
|
123
|
my $num = MIN_SENTENCE_WORDS + int rand MAX_SENTENCE_WORDS; |
|
149
|
45
|
|
|
|
|
90
|
my $words = ucfirst $self->words($num); |
|
150
|
45
|
|
|
|
|
78
|
return $words . _get_punctuation(); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Dan Church (h3xxgmxcom) |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Copyright (C) 2023 Dan Church. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
|
168
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 AVAILABILITY |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
The latest version of this library is likely to be available from CPAN as well |
|
173
|
|
|
|
|
|
|
as: |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 THANKS |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Thanks to Sebastian Carlos's L |
|
180
|
|
|
|
|
|
|
(L) for the inspiration. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
|
183
|
|
|
|
|
|
|
1; |