in reply to passing file handle to functions

If using a separate function for data processing, it's generally best to keep the file reading out of it. I'd just pass a reference to the array. Heck, you can pass the array itself - Perl passes it internally as a reference anyway, and you don't lose any efficiency so long as you don't assign (copy) the contents.

GOOD:

fast(@data); sub fast { my $x = $_[0]; }
BAD:
slow(@data); sub slow { my @arr = @_; my $x = $arr[0]; }
ALSO GOOD (but not as pretty):
fast(\@data); sub fast { my $arr = $_[0]; my $x = $arr->[0]; }