Always, ALWAYS check the return value of a command such as
open:
open INPUT "myfile.txt" || die "Cannot open file: $!";
This will save you hours of aggregate troubleshooting when your program fails silently. (The special variable
$! contains the error message. Print it to discover why the file couldn't be opened.)