|There's more than one way to do things|
"... this is my first time ever reading from a file
Well, you have a teacher and this is a pretty basic stuff, there are some particularities about how to read a file that you need to know, ask him/her before to truncate something important.
Yes, if your handbook is so poor that forget to tell you about how to open a file, at least use perldoc to examine the function open
My file is called x.txt but the program reads the file name from the keyboard so it could be whatever
Well, you wrote THIS program for your homework, isn't? You can change your own program
Please, show us a little code