File Coverage

blib/lib/Lingua/IT/Hyphenate.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 22 23 95.6


line stmt bran cond sub pod time code
1             package Lingua::IT::Hyphenate;
2            
3             require Exporter;
4             @ISA = qw(Exporter);
5             @EXPORT_OK = qw(sillabe);
6            
7 1     1   1052 use vars qw( $VERSION $_V $_C );
  1         2  
  1         1081  
8            
9             $VERSION = "0.14";
10            
11             $_V = "[aeiouàèéìòù]";
12             $_C = "[b-df-hj-np-tv-z]";
13            
14             sub sillabe {
15 1     1 0 50 my(@words) = split(/[^a-zA-Zàèéìòù'0-9]+/, join(" ", @_)); #'
16 1         3 my @result = ();
17 1         3 foreach $word (@words) {
18             #DEBUG print "word $word --> ";
19 2         49 $word =~ s/($_V)([bcfgptv][lr])/$1=$2/gi;
20 2         35 $word =~ s/($_V)([cg]h)/$1=$2/gi;
21 2         26 $word =~ s/($_V)(gn)/$1=$2/gi;
22 2         37 $word =~ s/($_C)\1/$1=$1/gi;
23 2         36 $word =~ s/(s$_C)/=$1/gi;
24 2         161 1 while $word =~ s/($_V*$_C+$_V+)($_C$_V)/$1=$2/gi;
25 2         190 1 while $word =~ s/($_V*$_C+$_V+$_C)($_C)/$1=$2/gi;
26 2         77 $word =~ s/^($_V+$_C)($_C)/$1=$2/gi;
27 2         72 $word =~ s/^($_V+)($_C$_V)/$1=$2/gi;
28 2         7 $word =~ s/^=//;
29 2         5 $word =~ s/=$//;
30 2         8 $word =~ s/=+/=/g;
31             #DEBUG print "$word\n";
32 2         12 push(@result, split(/=/, $word));
33             }
34 1         7 return @result;
35             }
36            
37             1;
38            
39             __END__