I strongly suggest that you reconsider implementing this task as a "command line". They can save some work if the task is sufficiently simple and your typing skills are adequate. Only you can judge whether you are more comfortable typing on the command line or in an editor. I am quite sure that this task is to complex for the command line, especially for a beginner. You require input from a terminal and a file. Your cannot use stdin for both. Open the file explicitly. Another big reason for using .pl files is that they save your work. Requirements change. Next week you may be back asking us how to keep score. You should not have to start over.