Sometimes an eq by is() or a regular expression by like() just isn't good enough. For example what if you would like to check the rand() function of perl? Its result must be between 0 (inclusive) and 1 (non inclusive).

In other case you might have a function that should happen within a certain period of time. You don't have an exact expectation but you know the ellapsed time must be between a lower and upper limit.

cmp_ok compares with any operator you like.

examples/intro-testing/cmp_ok.t
#!/usr/bin/perl
use strict;
use warnings;

use Test::More tests => 2;

my $start = time;
wait_for_input_with_timeout(3);
my $end = time;

cmp_ok $end - $start, ">=", 2, "process was waiting at least 2 secs";
cmp_ok $end - $start, "<=", 3, "process was waiting at most 3 secs";

sub wait_for_input_with_timeout {
    sleep rand shift;
}

perl examples/intro-testing/cmp_ok.t

1..2
ok 1 - process was waiting at least 2 secs
ok 2 - process was waiting at most 3 secs

perl examples/intro-testing/cmp_ok.t

1..2
not ok 1 - process was waiting at least 2 secs
#   Failed test 'process was waiting at least 2 secs'
#   at examples/intro/cmp_ok.t line 11.
#     '0'
#         >=
#     '2'
ok 2 - process was waiting at most 3 secs
# Looks like you failed 1 test of 2.