File Coverage

blib/lib/Telugu/TGC.pm
Criterion Covered Total %
statement 9 51 17.6
branch 0 12 0.0
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 12 70 17.1


line stmt bran cond sub pod time code
1             package Telugu::TGC;
2              
3 1     1   120644 use strict;
  1         2  
  1         48  
4 1     1   5 use warnings;
  1         1  
  1         78  
5 1     1   661 use utf8;
  1         294  
  1         6  
6              
7             our $VERSION = '1.1';
8              
9             my @dheerga = ("ా", "ి", "ీ", "ు", "ూ", "ృ", "ౄ", "ె", "ే", "ై", "ొ", "ో", "ౌ", "ం", "ఁ", "ః", "ఀ");
10             my $visarga = "్";
11             my @consonant = ( "క", "ఖ", "గ", "ఘ", "ఙ", "చ", "ఛ", "జ", "ఝ", "ఞ", "ట", "ఠ",
12             "ణ", "త", "థ", "ధ", "ప", "ఫ", "బ", "భ", "మ", "య",
13             "డ", "ఢ", "ర", "ఱ", "ల", "ళ", "ఴ", "వ", "శ", "ష", "స", "హ" );
14              
15             my %dheerga = map { $_ => 1 } @dheerga;
16             my %consonant = map { $_ => 1 } @consonant;
17              
18             sub new {
19 0     0 0   my ($class) = @_;
20 0           return bless {}, $class;
21             }
22              
23             sub tgc {
24 0     0 0   my ($class, $string) = @_;
25              
26 0           my $counter = 0;
27 0           my @tgc;
28             my @temp;
29              
30 0           my @array = split("", $string);
31              
32 0           while($counter <= $#array) {
33 0           my $element = $array[$counter];
34 0           $counter++;
35              
36 0 0         if(exists($consonant{$element})) {
37 0           @temp = ();
38 0           push @temp, $element;
39 0           $element = $array[$counter];
40 0 0         if(exists($dheerga{$element})) {
41 0           $counter++;
42 0           push @temp, $element;
43 0           push @tgc, join("", @temp);
44 0           next;
45             }
46 0 0         if($element eq $visarga) {
47 0           push @temp, $element;
48 0           $counter++;
49 0           while(1) {
50 0           $element = $array[$counter];
51 0 0         if(exists($consonant{$element})) {
52 0           push @temp, $element;
53 0           $counter++;
54 0           $element = $array[$counter];
55 0 0         if($dheerga{$element}) {
56 0           push @temp, $element;
57 0           $counter++;
58 0           last;
59             }
60 0 0         if($element eq $visarga) {
61 0           push @temp, $element;
62 0           $counter++;
63 0           next;
64             }
65 0           last;
66             }
67             else {
68 0           last;
69             }
70             }
71             }
72 0           push @tgc, join("", @temp);
73 0           next;
74             }
75             else {
76 0           push @tgc, $element;
77 0           next;
78             }
79             }
80              
81 0           return @tgc;
82             }
83              
84             1;
85             __END__