in reply to reading files in binary mode

$file is not read because you never open it.

open FILE, "< $file";