Thanks for elaborating on utf8 and suggesting on a way forward with my questions. As is frequently the case, the monastery has another thread going to discuss the same issue: Can we write multi-threaded scripts ?. I looked at the reference that localshop posted and found code that uses perl's native language to thread. I would prefer not to have to use a module just for this little task. I must say, however that I fall short on my first attempt in some ways. Output then source:

$ ./2.fork.pl 
this is task 1 with pid 0
Waiting for child processes..
this is task 2 with pid 0
this is task 3 with pid 0
44
bing's translation is 
unctuous hypocrisy flowing from the tube

елейным лицемерие течет из трубки

 English -> Русский 
Child with PID=23085 finished..
43
42
41
slept 5
40
39
38
ERROR Oops! Something went wrong and I can't translate it for you :(
yandex's translation is 
Child with PID=23086 finished..
37
36
slept 10
35
google's translation is 
unctuous hypocrisy flowing from the tube

неприступное лицемерие, вытекающее из трубки
(nepristupnoye litsemeriye, vytekayushcheye iz trubki)

Translations of unctuous hypocrisy flowing from the tube
 English -> Русский 

unctuous hypocrisy flowing from the tube
    неприступное лицемерие, вытекающее из трубки, елейное лицемерие течет из трубки
Child with PID=23087 finished..
Done.
$ cat 2.fork.pl 
#!/usr/bin/perl -w
use 5.011;

my $string = "unctuous hypocrisy flowing from the tube";

my $pid1 = fork();
if ( $pid1 == 0 ) {    # Task 1
    say "this is task 1 with pid $pid1";
    my $command = "trans :ru -e bing \"$string\" >1.bing.txt"; 
    system("$command");
    say "bing's translation is ";
    system("cat 1.bing.txt");
    exit 0;
}

my $pid2 = fork();
if ( $pid2 == 0 ) {    # Task 2
    say "this is task 2 with pid $pid2";
    sleep 5;
    say "slept 5";
    system("trans :ru -e yandex \"$string\" >1.yandex.txt");
    say "yandex's translation is ";
    system("cat 1.yandex.txt");
    exit 0;
}

my $pid3 = fork();
if ( $pid3 == 0 ) {    # Task 3
    say "this is task 3 with pid $pid3";
    sleep 10;
    say "slept 10";
    system("trans :ru -e google \"$string\" >1.google.txt");
    say "google's translation is ";
    system("cat 1.google.txt");
    exit 0;
}

say "Waiting for child processes..";
my $counter = 45;
local $SIG{ALRM} = sub {
    say --$counter;
    alarm 1;
};
alarm 1;

while ((my $pid = wait) != -1) {
    say "Child with PID=$pid finished..";
}

alarm 0;
say "Done.";
__END__

Even with all the say statements dropped in, I find execution hard to follow. I'm baffled that pid's are zero within a block, but not so when they finish. What alarm truly does here is unclear. Finally, there is no code to kill pid's when the timer reaches zero.

I'm also fishing for code that would do this within the following loop:

print "Get other translations(y/n)?: "; my $prompt = <STDIN>; chomp $prompt; if ( $prompt eq ( "y" | "Y" ) ) { my @translators = qw /yandex bing/; for my $remote (@translators) { my $trans_munge = path( $vars{translations}, "$remote." . $munge + ); ## use trans shell say "getting translation from $remote"; system("trans :$lang -e $remote file://$in_path >$trans_munge"); }

Again, thanks for the very helpful comments.


In reply to Re^2: using online translation engines with perl by Aldebaran
in thread using online translation engines with perl by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.