No, you got the error saying that $filename.fa is uninitialized.
So perl saw that as a variable name while you intended to only use $filename instead.
In order to delimit the variable name you can use this syntax: "${filename}.fa".
Good luck, hexcoder