in reply to File test -T (text) and quoted filenames

open (FILE, "<" . $quotedfullelementpath) or die "Can't open file +$quotedfullelementpath:$!\n"; while (<FILE>) { binmode(FILE); my $line1 = unpack("H*", $_); if ($line1 =~ /0d/)

You have the binmode in the wrong place.    You have to use it right after the open and before the while loop.

open (FILE, "<" . $quotedfullelementpath) or die "Can't open file +$quotedfullelementpath:$!\n"; binmode(FILE); while (<FILE>) {

Or you could set binmode from open:

open (FILE, "<:raw" . $quotedfullelementpath) or die "Can't open f +ile $quotedfullelementpath:$!\n"; while (<FILE>) {

Because you are using unpack you could be matching one byte that has a "0" nybble and the next byte that has a "d" nybble, for example "10d2".    You need to just search for the byte that has the value "\x0d":

if (/\x0d/)