use warnings # FATAL => 'all' ; use strict; use Test::More # tests => ?? + 1 # Test::NoWarnings adds 1 test 'no_plan' ; use Test::NoWarnings; my $bases = 'AGCT'; my $agct = qr{ [\Q$bases\E] }xms; my ($no_repeat) = map qr{ $_ }xms, join ' ', map { qr{ (?! \Q$_\E $agct* \Q$_\E) }xms } split //, $bases ; my $sub_string = qr{ \b $no_repeat $agct{1,4} \b }xms; my $pair = qr{ $sub_string , $sub_string }xms; VECTOR: for my $ar_vector ( "all the following should be accepted", [ 'A,G', 1, '' ], [ 'AG,CT', 1, '' ], [ 'TC,CA', 1, '' ], [ 'GAT,CGA', 1, '' ], [ 'CGAT,TG', 1, '' ], [ 'CGAT,CTGA', 1, '' ], "all the following should be rejected", [ '', 0, 'empty string' ], [ ' ', 0, 'space' ], [ ',', 0, 'comma, no sub-strings' ], [ ',G', 0, 'missing 1st sub-string' ], [ 'G,', 0, 'missing 2nd sub-string' ], [ 'ACGT', 0, 'missing comma' ], [ 'X,A', 0, 'incorrect character' ], [ 'AA,G', 0, 'repetition of character in 1st substring' ], [ 'ACGTA,G', 0, 'repetition of character in 1st substring' ], [ 'AC,GGC', 0, 'repetition of character in 2nd sub-string' ], [ 'AC,ACGTA', 0, 'repetition of character in 2nd sub-string' ], [ 'ATGA,TGG', 0, 'repetition in both sub-strings' ], [ 'ATCXG,AAC', 0, 'incorrect character and repetition' ], ) { if (not ref $ar_vector) { note $ar_vector; next VECTOR; } my ($str, $match, $msg) = @$ar_vector; if ($match) { ok $str =~ $pair, qq{'$str'}; } else { ok $str !~ $pair, qq{'$str': $msg}; } } # end for VECTOR