Assuming there are reasons for the way you coded that routine (and you may wish to check for a better way to code it, although my guess is that is a striped-down version to focus on just the problem you present here), I think what I would do (although there are many more knowledgable here than I, and I hope they will correct me if I am in error) would be thus:
sub openFile {
my (@entries, $filename);
$filename = $file1 if ($file1);
$filename = $file2 if ($file2);
open(FH, $filename) or die($!);
@entries = <FH>;
close(FH)
# Other processing here
}