in reply to Using regexp with binary data

use the /s modifier so that "dot" matches any character (see perldoc -f perlre), including newlines, and all 6 will match:
$data =~ /$_/s