http://www.perlmonks.org?node_id=744914


in reply to RFC: Basic debugging checklist

Check for unprintable characters and identify them by their ASCII codes using ord
print ":$_:", ord($_), "\n" for (split //, $str)
That, IMO, makes it hard to spot unexpected unprintable characters because you turn ALL characters into numbers. I often do:
my $copy = $str; $str =~ s/([^\x20-\x7E])/sprintf '\x{%02x}', ord $1/eg; print $str, "\n";
which leaves all printable ASCII characters as is, and turns all other characters into hex escapes.