in reply to Weird underscore/whitespace failing regex

use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper($str);

This will show you what's insider your $str.