for my $file (@texts) {
local $/ = "";
open my $fh, '<:crlf', $file or die;
my $base_name = path("$file")->basename;
my $out_file = path( $out_dir, $base_name )->touchpath;
say "out_file is $out_file";
## time it
use Benchmark;
my $t0 = Benchmark->new;
while (<$fh>) {
print "New Paragraph: $_";
my $r = get_trans( $wgt, $_ );
for my $trans_rh ( @{ $r->{data}->{translations} } ) {
my $result = $trans_rh->{translatedText};
say "result is $result ";
my @lines = split /\n/, $result;
push @lines, "\n";
path("$out_file")->append_utf8(@lines);
sleep(1);
}
}
my $t1 = Benchmark->new;
my $td = timediff( $t1, $t0 );
print "$file took:", timestr($td), "\n";
sleep(3);
close $fh;
####
/home/bob/Documents/meditations/castaways/Translate1/data/84-0.txt took:1180 wallclock secs (23.34 usr + 1.36 sys = 24.70 CPU)
$
####
$ cat 1.google.sh
#!/bin/bash
pwd
make clean
perl Makefile.PL
make
make test
make install
ls
cd blib
cd script
./3.my_script.pl
$
####
New Paragraph: Are you mad, my friend? said he. Or whither does your
senseless curiosity lead you? Would you also create for yourself and the
world a demoniacal enemy? Peace, peace! Learn my miseries and do not seek
to increase your own.
####
#!/usr/bin/perl -w
use 5.011;
use WWW::Google::Translate;
use Data::Dumper;
use open OUT => ':utf8';
use Path::Tiny;
use lib ".";
use translate;
binmode STDOUT, 'utf8';
use POSIX qw(strftime);
####
my %WriteMakefileArgs = (
NAME => 'Translate1',
AUTHOR => q{gilligan },
VERSION_FROM => 'lib/Translate1.pm',
LICENSE => 'artistic_2',
MIN_PERL_VERSION => '5.006',
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
},
TEST_REQUIRES => {
'Test::More' => '0',
},
PREREQ_PM => {
#'ABC' => '1.6',
#'Foo::Bar::Module' => '5.0401',
},
EXE_FILES => ['lib/3.my_script.pl'],
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Translate1-*' },
);