You are looking at a very old, but free version of the course. If you are interesed the most recent version, check it out on the Perl Maven site.

7.13. External test file

Separating the test cases from the code.

Example 7-6. examples/bc/bc5a.pl

#!/usr/bin/perl
use strict;
use warnings;

use Expect;
use Test::More qw(no_plan);
$Expect::Log_Stdout = 0;


open my $fh, "<", "bc_input.txt" or die "Could not open bc_input.txt";

my @sets;
while (my $line = <$fh>) {
    chomp $line;
    push @sets, [split /\s*,\s*/, $line];
}

my $e = Expect->new;
$e->spawn("bc") or die "Could not start bc\n";
$e->expect(undef, "warranty") or die "no warranty\n";

foreach my $set (@sets) {
    $e->send("$$set[0]\n");
    ok($e->expect(1, $$set[1]), $$set[0]);
}
$e->send("quit\n");

If you are interested in on-site trainings by the author, please contact me directly.