in reply to Re^5: Error binmode() on unopened filehandle
in thread Error binmode() on unopened filehandle

Your initial premise that you could read binary data from the DATA file handle is wrong.

Works for me.

use feature qw( say ); binmode DATA if $ARGV[0]; while (<DATA>) { say sprintf "%v02X", $_; } __DATA__ abc def
>perl a.pl 0 61.62.63.0A 64.65.66.0A >perl a.pl 1 61.62.63.0D.0A 64.65.66.0D.0A