in reply to varaible to filehandle -alack!

Using $1 as a filehandle is dreadful. Use a plain variable.
Also, setting the value of %seen to something smaller (like 1 or undef) can save you little memory if the file is big.