sub stest { my $str = shift; foreach (@_) { substr($str,$_-1,2) =~ /^(10|01)/ || return; } return 1; } #USE: stest( $bit_string, @indexes )