in reply to specifying path to files

I am not sure what the solution to your specific problem is, but you should consider the following:

There is at least 1 typo in your posted code. use CGI needs a semicolon.

Using the strictures can help prevent other simple mistakes:

use warnings; use strict;
This will force you to declare all yor variables using my, which will be well worth the effort and time.

The following line looks odd:

@line = pop(@line);
pop actually modifies the array.

The following line also looks odd:

$inum = ++$inum;
++$inum may be sufficient.

Declaring a sub in the middle of your main code is a little confusing.

Your sub indexArray, while it may earn you a low Perl golf score, should probably not be so compact. It would benefit greatly by some added whitespace.

I hope this helps.