7.9. Reduce output

We don't want to see all the output bc generates and then try to look for the correct responses or the error messages. We'd prefer just see ok or not ok

Example 7-4. examples/bc/bc4.pl

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

use Expect;
use Test::More qw(no_plan);

$Expect::Log_Stdout = 0;

my $e = Expect->new;
$e->raw_pty(1);
$e->spawn("bc") or die "Cannot run bc\n";
$e->expect(1, "warranty") or die "no warranty\n";
$e->send("23+7\n");
ok($e->expect(1, 30));

  • $Expect::Log_Stdout = 0; - turn off the printing to the screen


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

Online courses: