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.

5.6. Print only ok/not ok

Example 5-6. examples/intro/t03_calc.t

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

my $result;

$result = `./mycalc 1  + 1`;
if ( $result == 2 ) {
    print "ok\n";
}
else {
    print "not ok\n";
}

$result = `./mycalc 2 + 2`;
if ( $result == 4 ) {
    print "ok\n";
}
else {
    print "not ok\n";
}

$result = `./mycalc 2 + 2 + 2`;
if ( $result == 6 ) {
    print "ok\n";
}
else {
    print "not ok\n";
}

# We replaced the "system" calls with backtick in order to catch the STDOUT
# It is extreamly verbose and we are repeating the same code a lot of times

Output:

Example 5-7. examples/intro/t03_calc.out

ok
ok
not ok

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