Perl Expect bindings – Simple example

Hello World file (hello.pl)

#!/usr/bin/perl
use strict;
use warnings;
use diagnostics; print "-----------\n",
 "Hello World\n",
 "-----------\n";

Test Perl file with expect bindings (test.pl)

#!/usr/bin/perl
use strict;
 use warnings;
 use diagnostics;
use Expect;
my $timeout=5;
foreach my $i (1..20)
 {
 my $exp = Expect->spawn("./hello.pl")
 or die "Unexpected error : $!\n";
$exp->expect($timeout);
 }