in reply to Reading binary file is not accurate ?

You should check whether the "open" statement succeeds on the input file:
open (DATA, "$indir/$infile") or die "Open failed on $indir/$infil +e: $!\n";