Help,
Having trouble getting the translation... code follows:
Getting an error -> usage: ./translate.pl autobad.log at babel.pl line 9. Thanks
Having trouble getting the translation... code follows:
Getting an error -> usage: ./translate.pl autobad.log at babel.pl line 9. Thanks
Code:
#!/usr/bin/perl
use strict; use warnings;
use Babelfish;
# input file to translate
# specified as command line argument
my $input_file = shift;
if (not defined $input_file) {
die "usage: ./translate.pl autobad.log";
}
# create the Babelfish service
my $service = Babelfish->new(
service => 'Babelfish',
);
# check for errors
if (not defined $service) {
die "Babelfish server unavailablen";
}
# open input file to be translated
open my $ifh, '<', $input_file
or die "Could not open $input_file for reading: $!n";
# translate
# write translation to output file handle
my $ret = $service->translate(
source => 'Chinese', # source language
destination => 'English', # destination language
text => $ifh, # file handle to read from
ofh => *STDOUT # file handle to write to
);
if (not defined $ret) {
print "Error while translating to English";
}