We must strip the trailing newline with `echo -n` before we pass it to perl to convert the hex to binary, not after.