While many people know what files and filehandles are in Perl, there are many times that people forget exactly how they should be used. Too often people open files incorrectly, causing data to be lost, or they expect a file to exist, when it really doesn't, and their program lacks the proper error reporting to alert them. Let's fix these problems up first. In addition, it's best to leave a variable holding a filename to hold JUST a filename, or you'd have to make adjustments every time you need to read the filename out of the variable.
Error handling is very important when using files.
This remark on Perl's behalf will let you know that something is wrong with your request to open a file. This is only true when this is the ONLY statement in the while loop's condition. If you change the value, Perl changes its definition of a line. They are not the same value, mind you. LIST is a regular list.