in reply to Killer byte tripping up Perl?

If you're reading binary data, you should always binmode the filehandle, or use the three-argument open and specify the :raw layer. Don't use a plain print to show the data, use Data::Dump or Data::Dumper with $Data::Dumper::Useqq=1;. Plus, note that your while (<CMD>) is still going to split the input on $/ (if you haven't set it to anything else), so you might want to look into read to read fixed-size chunks of data ($/ has a special mode for that, but I like read better).

Update: I see haj and Laurent_R have made similar points too. In particular, don't chomp binary data!

Another note: I wrote about "safer" piped opens here.