use strict;
use Config;
my $PerlV = $Config{api_versionstring};
print "Input file: $ARGV[0]\n";
print "Output file: $ARGV[1]\n";
open INPUT, "<$ARGV[0]" or die "Can not read file $ARGV[0]\n";
open OUTPUT, ">$ARGV[1]" or die "Can not read file $ARGV[1]\n";
if ($PerlV =~/5[_\.]8[_\.]0/){
binmode(OUTPUT,":utf8")
}else{
binmode OUTPUT;
}
my @text_arr = ;
my $text_str = "@text_arr";
my @LanguageName = qw ( ''
Unicode::Indic::Devanagari
Unicode::Indic::Bengali
Unicode::Indic::Gurmukhi
Unicode::Indic::Gujarati
Unicode::Indic::Oriya
Unicode::Indic::Tamil
Unicode::Indic::Telugu
Unicode::Indic::Kannada
Unicode::Indic::Malayalam
);
my $mode = 0;
my $tolang;
my $buf;
my $uselang;
foreach my $ch (split (//, $text_str),' '){
if ($mode == 0 and $ch ne '^'){
print OUTPUT $ch;
next;
}
if ($mode == 0 and $ch eq '^'){
$mode = 1; # Start transliteration.
next;
}
if ($mode == 2 and $ch eq '^'){
print OUTPUT $uselang->translate($buf);
$buf = '';
$mode = 0 ; # End of transliteration text.
next;
}
if ($mode == 1){
my $lang = $ch;
$lang = $LanguageName[$ch];
eval "use $lang;";
$uselang = $lang->new();
$mode = 2;
next;
}
if ($mode == 2 and $ch ne '^'){
$buf .= $ch;
next;
}
}
__END__
=head1 NAME
transliterate -Perl program to transliterate Indic language HTML page contents from roman script encoding to corresponding UNICODE fonts.
=head1 SYNOPSIS
transliterate.pl