line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Greeting; |
2
|
3
|
|
|
3
|
|
94669
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
119
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
4
|
3
|
|
|
3
|
|
43
|
use v5.12.3; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
140
|
|
5
|
3
|
|
|
3
|
|
3130
|
use utf8; |
|
3
|
|
|
|
|
27
|
|
|
3
|
|
|
|
|
16
|
|
6
|
3
|
|
|
3
|
|
1456
|
use self; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.0.3'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $last = ""; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
|
|
|
|
|
|
my %opt = args; |
14
|
|
|
|
|
|
|
$opt{language} = "en" unless defined $opt{language}; |
15
|
|
|
|
|
|
|
$opt{target} = "guest" unless defined $opt{target}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $realfile = ""; |
18
|
|
|
|
|
|
|
my $db = "Acme/Greeting/$opt{language}.pm"; |
19
|
|
|
|
|
|
|
for my $prefix (@INC) { |
20
|
|
|
|
|
|
|
$realfile = "$prefix/$db"; |
21
|
|
|
|
|
|
|
last if (-f $realfile); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my @greeting = (); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $DB; |
27
|
|
|
|
|
|
|
open($DB, "<:utf8", $realfile) and do { |
28
|
|
|
|
|
|
|
while (<$DB>) { |
29
|
|
|
|
|
|
|
chomp; |
30
|
|
|
|
|
|
|
if ( m/^=item\ (.+)$ /x ) { |
31
|
|
|
|
|
|
|
push @greeting, $1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
close $DB; |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
if (@greeting == 0) { |
38
|
|
|
|
|
|
|
push @greeting, __PACKAGE__ . ' says hi, $u'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $greeting = $last; |
42
|
|
|
|
|
|
|
while ($greeting eq $last) { |
43
|
|
|
|
|
|
|
$greeting = $greeting[ int(rand(@greeting)) ]; |
44
|
|
|
|
|
|
|
$greeting =~ s/\$u/$opt{target}/g; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$last = $greeting; |
48
|
|
|
|
|
|
|
return $greeting; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
"Greeting"; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |