use round brackets around your if statement...without the brackets it's probably testing (if $name), and there's nothing to bind the substitution to...and perl tries to use default $_ for the substitution which is empty.
the hardest line to type correctly is: stty erase ^H