Translate.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 50 CC 5 SCAR 30.9
CC
5
Cov
0%
translate
30.0
new
2.0
BEGIN
2.0
CRAP 22.0
1 package Unicode::Indic::Translate;
2 use strict;
3 our $VERSION = 0.01;
4
5 sub new{
6 my $proto = shift;
7 my $class = ref($proto)||$proto;
8 my $self = {
9 @_
10 };
11 bless $self, $class;
12 }
13
14
15 sub translate{
16 my $self = shift;
17 my $fromlang = $self->{FromLang};
18 my $tolang = $self->{ToLang};
19 my $infile = $self->{InFile};
20 my $outfile = $self->{OutFile};
21 $tolang = "Unicode::Indic::$tolang";
22 $fromlang = "Unicode::Indic::$fromlang";
23 open(INPUT,"<$infile");
24 open(OUTPUT,">$outfile");
25 binmode(INPUT,":utf8") unless $fromlang eq 'Unicode::Indic::Phonetic';
26 binmode(OUTPUT,":utf8") unless $tolang eq 'Unicode::Indic::Phonetic';
27 my @input = <INPUT>;
28 my $buf = "@input";
29 eval "use $tolang";
30 my $out = $tolang->new();
31 if ($fromlang ne 'Unicode::Indic::Phonetic'){
32 eval "use $fromlang;";
33 print "from lang is $fromlang\n";
34 my $in = $fromlang->new();
35 $buf = $in->romanise($buf);
36 }
37 print "tolang is $tolang \n";
38 $buf = $out->translate($buf) unless $tolang eq 'Unicode::Indic::Phonetic';
39 print OUTPUT "$buf\n";
40 }
41
42 1;
43