in reply to Scratching my head...
Change that to:
open INFILE, "$inputfn" or die "Error reading input file: $!\n";
open(INFILE, "$inputfn") || die "Error reading input file: $!\n";
The problem is the precedence of || and ",". In your
code, if open fails to open $inputfn for any reason,
it tries to "open" the die statement! Use parens to
say what you really mean, or use the ultra-low priority
"or" operator, which makes the comma act as you might
(Of course, this applies to both of your opens.
When in doubt, use parenthesis around all your function