| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lingua::PigLatin::Bidirectional; |
|
2
|
3
|
|
|
3
|
|
69603
|
use 5.008005; |
|
|
3
|
|
|
|
|
12
|
|
|
|
3
|
|
|
|
|
119
|
|
|
3
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
98
|
|
|
4
|
3
|
|
|
3
|
|
26
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
102
|
|
|
5
|
3
|
|
|
3
|
|
3050
|
use utf8; |
|
|
3
|
|
|
|
|
32
|
|
|
|
3
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
123
|
use base qw(Exporter); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
1924
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(to_piglatin from_piglatin); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub to_piglatin { |
|
13
|
4
|
|
|
4
|
1
|
5475
|
my $str = shift; |
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
41
|
$str =~ s{\b # See if each given word starts w/ or w/o |
|
16
|
|
|
|
|
|
|
( qu # 1. qu (e.g. question => estionquay) |
|
17
|
|
|
|
|
|
|
| [cgpstw]h # 2. digraphs |
|
18
|
|
|
|
|
|
|
| [^\W0-9_aeiou] # 3. any "word" character other than |
|
19
|
|
|
|
|
|
|
# 0-9, _ and vowels |
|
20
|
|
|
|
|
|
|
)? |
|
21
|
|
|
|
|
|
|
( [a-z]+ ) # and then alphabet character(s) |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
29
|
100
|
|
|
|
70
|
if ( my $pre = $1 ) { |
|
25
|
|
|
|
|
|
|
# if the first rule applies, append former part and add -ay |
|
26
|
21
|
|
|
|
|
31
|
my $post = $2; |
|
27
|
21
|
100
|
|
|
|
127
|
$pre =~ /\A [A-Z]/x |
|
28
|
|
|
|
|
|
|
? ucfirst($post) . lcfirst($pre) . 'ay' |
|
29
|
|
|
|
|
|
|
: $post . $pre . 'ay' ; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
else { |
|
32
|
|
|
|
|
|
|
# otherwise add -way |
|
33
|
8
|
|
|
|
|
42
|
$2 . 'way'; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
}iegxms; |
|
36
|
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
22
|
return $str; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub from_piglatin { |
|
41
|
4
|
|
|
4
|
1
|
5131
|
my $str = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
42
|
$str =~ s{ # See if each given word consists of... |
|
44
|
|
|
|
|
|
|
( [a-z]+ )way # alphabet character(s) followed by "way" |
|
45
|
|
|
|
|
|
|
| # OR... |
|
46
|
|
|
|
|
|
|
( [a-z]+? ) # zero or alphabet character(s) followed by... |
|
47
|
|
|
|
|
|
|
( qu # 1. qu |
|
48
|
|
|
|
|
|
|
| [cgpstw]h # 2. digraphs |
|
49
|
|
|
|
|
|
|
| [^\W0-9_aeiou] # 3. any "word" character other than |
|
50
|
|
|
|
|
|
|
# 0-9, _ and vowels |
|
51
|
|
|
|
|
|
|
)ay # and trailing "ay" |
|
52
|
|
|
|
|
|
|
\b} |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
29
|
100
|
|
|
|
73
|
if ($1) { |
|
55
|
8
|
|
|
|
|
58
|
$1; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
else { |
|
58
|
21
|
|
|
|
|
37
|
my $pre = $2; |
|
59
|
21
|
|
|
|
|
33
|
my $post = $3; |
|
60
|
21
|
100
|
|
|
|
135
|
$pre =~ m/\A [A-Z]/x |
|
61
|
|
|
|
|
|
|
? ucfirst($post) . lcfirst($pre) |
|
62
|
|
|
|
|
|
|
: $post . $pre ; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
}iegxms; |
|
65
|
|
|
|
|
|
|
|
|
66
|
4
|
|
|
|
|
24
|
return $str; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
|
70
|
|
|
|
|
|
|
__END__ |