like(value, qr/expected regex/, name);


What if you don't want or can't realisticly expect an exact match with the result?

You can use like that compares with regex =~.


examples/test-more/show_last_update.pl
use strict;
use warnings;
use 5.010;

use lib 'lib';
use MyTools qw(last_update);

say (last_update());

This page was last updated at 2020-11-10T09:19:38


examples/test-more/t/last_update.t
use strict;
use warnings;

use MyTools qw(last_update);

use Test::More tests => 3;

my $resp = last_update();
diag $resp;
ok( $resp =~ /^This page was last updated at/, 'last_update =~');

like( $resp, qr/^This page was last updated at/, 'last_update like');

like( $resp,
    qr/^This page was last updated at \d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d$/, 'last_update full match');

prove t/last_update.t


# This page was last updated at 2020-11-10T09:20:48
t/last_update.t .. ok
All tests successful.
Files=1, Tests=3,  0 wallclock secs ( 0.01 usr  0.01 sys +  0.13 cusr  0.00 csys =  0.15 CPU)
Result: PASS