use Test::Simple tests => 14; use strict; # # PUT THE REGEXP TO TEST HERE # my $testregexp = qr/\x26\x67(?!.{0,6}\x26\x67).{8}/s; sub mytest( $ ) { return( ( $_[0] =~ m/$testregexp/ ) ? 1 : 0 ); } # tests ok( mytest( "\x26\x67________" ), "lead bytes followed by 8 clear bytes" ); ok( !mytest( "\x26\x67_______" ), "lead bytes followed by only 7 clear bytes" ); ok( mytest( "\x26\x67_________" ), "lead bytes followed by 9 clear bytes" ); ok( !mytest( "\x26\x67\x26\x67______" ), "lead bytes with 2 bad bytes" ); ok( !mytest( "\x26\x67_\x26\x67_____" ), "lead bytes with 2 bad bytes" ); ok( !mytest( "\x26\x67_____\x26\x67_" ), "lead bytes with 2 bad bytes" ); ok( !mytest( "\x26\x67______\x26\x67" ), "lead bytes with 2 bad bytes" ); ok( mytest( "\x26\x67________\x26\x67" ), "lead bytes with 1 bad byte inside the eight byte limit" ); ok( mytest( "\x26\x67_______\x26\x67" ), "lead bytes with 1 bad bytes" ); ok( !mytest( "\x26\x67\x26\x67\x26\x67____" ), "lead bytes with 2 sets of bad bytes" ); ok( !mytest( "\x26\x67\x26\x67_\x26\x67___" ), "lead bytes with 2 sets of bad bytes" ); ok( !mytest( "\x26\x67_\x26\x67\x26\x67___" ), "lead bytes with 2 sets of bad bytes" ); ok( !mytest( "\x26\x67_\x26\x67___\x26\x67" ), "lead bytes with 2 sets of bad bytes" ); ok( !mytest( "\x26\x67\x26\x67____\x26\x67" ), "lead bytes with 2 sets of bad bytes" ); #### C:\temp>perl -w regexp.t 1..14 ok 1 - lead bytes followed by 8 clear bytes ok 2 - lead bytes followed by only 7 clear bytes ok 3 - lead bytes followed by 9 clear bytes ok 4 - lead bytes with 2 bad bytes ok 5 - lead bytes with 2 bad bytes ok 6 - lead bytes with 2 bad bytes ok 7 - lead bytes with 2 bad bytes ok 8 - lead bytes with 1 bad byte inside the eight byte limit ok 9 - lead bytes with 1 bad bytes ok 10 - lead bytes with 2 sets of bad bytes ok 11 - lead bytes with 2 sets of bad bytes ok 12 - lead bytes with 2 sets of bad bytes ok 13 - lead bytes with 2 sets of bad bytes ok 14 - lead bytes with 2 sets of bad bytes