use strict; use warnings; use Test::More; my @good = ( 'nnxx.yy2 = 333 abc', 'nnxx.yy2 = 1 abc', 'nnxx.yy2 = 2345 abc', ); my @bad = ( 'foo', 'nnxxayy2 = 1 abc', 'nnxx.yy2 = 1a abc', ); my $re = qr/^\Qnnxx.yy2 = \E\d+\Q abc\E$/; plan tests => @good + @bad; for my $str (@good) { like ($str, $re, "$str matched"); } for my $str (@bad) { unlike ($str, $re, "$str not matched"); }