#!/usr/local/bin/perl -w

use strict "vars";
#-----------------------------------------------------------------------------
my $Line;
my $SelfTaskID;
my $PongTaskID;

$| = 1;

print("Ping about to get its own TaskID\n");
print(":::list self\n");
$Line = <STDIN>;
#----Read off EOF message
<STDIN>;
print("Ping self line is $Line\n");
($SelfTaskID) = ($Line =~ /:::TaskID=(\d*):::/);
print("Ping TaskID is $SelfTaskID\n");
print("Ping about to start pong\n");
print(":::create gettysburg.cs.miami.edu /home/escambia/geoff/perl/TERDS/PongTask\n");
print("Ping gets pong information\n");
print(":::list children\n");
$Line = <STDIN>;
#----Read off EOF message
<STDIN>;
print("Ping children is $Line\n");
($PongTaskID) = ($Line =~ /:::TaskID=(\d*):::/);
print("Pong task is is $PongTaskID\n");
do {
    print("Ping is sending a pong in 1 second\n");
    sleep(1);
    print(":::send $PongTaskID ping $SelfTaskID\n");
    print("Ping is waiting for a pong\n");
    do {
        $Line = <STDIN>;
        chomp($Line);
        } while ($Line !~ /^pong/);
    print("Ping got a pong\n");
    } while ($Line !~ /^pong end/);

#-----------------------------------------------------------------------------

