| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Hyphen::GenderInclusive; |
|
2
|
1
|
|
|
1
|
|
69396
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
29
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
388
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
1
|
|
|
1
|
0
|
85
|
my ( $class, %args ) = @_; |
|
10
|
1
|
|
33
|
|
|
10
|
$class = ref $class || $class; |
|
11
|
1
|
|
|
|
|
3
|
my $base_class = delete $args{class}; |
|
12
|
1
|
50
|
|
|
|
3
|
if ( !$base_class ) { |
|
13
|
0
|
|
|
|
|
0
|
croak "Missing class argument."; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
1
|
50
|
|
|
|
52
|
eval "require $base_class" or croak $@; |
|
16
|
1
|
|
|
|
|
18416
|
my $self; |
|
17
|
1
|
|
33
|
|
|
18
|
$self->{re} ||= delete( $args{re} ) || qr/[:*_]/; |
|
|
|
|
33
|
|
|
|
|
|
18
|
1
|
|
|
|
|
12
|
$self->{hyphenator} = $base_class->new(%args); |
|
19
|
1
|
|
|
|
|
986179
|
bless $self, $class; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub hyphenate { |
|
23
|
2
|
|
|
2
|
0
|
7
|
my ( $self, $word, $delim ) = @_; |
|
24
|
2
|
|
|
|
|
5
|
my $re = $self->{re}; |
|
25
|
2
|
|
|
|
|
75
|
$word =~ s/(?<=\w)($re)(?=\w)//; |
|
26
|
2
|
|
|
|
|
9
|
my $char = $1; |
|
27
|
2
|
|
|
|
|
7
|
my $pos = $-[0]; |
|
28
|
2
|
|
|
|
|
15
|
my @parts = $self->{hyphenator}->hyphenate($word); |
|
29
|
2
|
100
|
|
|
|
1015
|
if ($char) { |
|
30
|
1
|
|
|
|
|
4
|
for my $part (@parts) { |
|
31
|
4
|
100
|
|
|
|
19
|
if ( length($part) < $pos ) { |
|
32
|
3
|
|
|
|
|
11
|
$pos -= length($part); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
else { |
|
35
|
1
|
|
|
|
|
3
|
substr( $part, $pos, 0 ) = $char; |
|
36
|
1
|
|
|
|
|
2
|
last; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
2
|
50
|
|
|
|
6
|
if ( defined($delim) ) { |
|
41
|
0
|
|
|
|
|
0
|
return join( $delim, @parts ); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
else { |
|
44
|
2
|
50
|
|
|
|
15
|
return wantarray ? @parts : join( '-', @parts ); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |