in reply to @ARGV / Command Line Arguments

Your problem is the line

while (<>)

This is wrong for two reasons.

  1. You've gone to the trouble of opening a specific input filehandle, INPUT, so you should be reading from that.
  2. When you use the diamond operator, the first thing it does is to use shift to remove the first element from @ARGV. This means that there are now only two elements left in @ARGV and $ARGV[2] is undefined.

You should use

while (<INPUT>)

instead.

Look for the section on "I/O Operators" in perldoc perlop.

--
<http://www,dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg