Expect multiple values



examples/expect/random.pl
use strict;
use warnings;

my $x = rand();
if ($x < 0.3) {
    print "abc\n";
} elsif ($x < 0.6) {
    print "def\n";
} else {
    print "xyz\n";
}

examples/expect/random.t
use strict;
use warnings;

use Test::More tests => 1;
use Expect;


my $exp   = Expect->new( "$^X examples/expect/random.pl" );
my $val;
$exp->expect(
    2,
    [ "abc" => sub { $val = 1; } ],
    [ "def" => sub { $val = 1; } ],
);
ok $val;