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



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

use lib 'lib';
use MyTools qw(get_copyright get_copyright_broken);

say (get_copyright());
say (get_copyright_broken());

Copyright 2000-2020 Gabor Szabo, all rights reserved.
Copyright 2000-19120 Gabor Szabo, all rights reserved.


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

use MyTools qw(get_copyright get_copyright_broken);

use Test::More tests => 3;

like( get_copyright(),
    qr/Copyright 2000-\d{4} Gabor Szabo, all rights reserved./, 'copyright');

my $copyright = get_copyright_broken();

ok( $copyright =~ /Copyright 2000-\d{4} Gabor Szabo, all rights reserved./, 'use =~' );
like( $copyright,
    qr/Copyright 2000-\d{4} Gabor Szabo, all rights reserved./, 'use like');

1..2
ok 1 - copyright
not ok 2 - copyright
#   Failed test 'copyright'
#   at t/copyright.t line 12.
#                   'Copyright 2000-19120 Gabor Szabo, all rights reserved.'
#     doesn't match '(?^:Copyright 2000-\d{4} Gabor Szabo, all rights reserved.)'
# Looks like you failed 1 test of 2.