sub openFile {
my ($file, $accessMode) = @_;
my $err;
if (! defined($accessMode)) { # by default, open the file for reading
$accessMode = $MODE_READ;
}
if (exists($ACCESS_MODES{$accessMode})) {
if (! open(FILE, "$ACCESS_MODES{$accessMode}$file")) {
$err = $!;
if (defined($returnOnError)) {
return $FALSE;
}
&throwGenError("Can't open $file: $err"); # throw exception
}
} else {
&throwGenError("In openFile: Wrong access mode $accessMode");
}
return FILE;
}
####
sub func1 {
my (@fileContent,@temp, @comment);
my $contentFh = &openFile($file1);
while (my $line = <$contentFh >) {
...
push(@fileContent,&func2($line));
...
}
}
close($contentFh);
return \@fileContent;
}
sub func2 {
my ($user) = @_;
my @groupsFile;
my $groupsFh = &openFile($file2);
@groupsFile = <$groupsFh>;
close($groupsFh);
...
return @groupsFile;
}
##
##
readline() on closed filehandle FILE at /var/www/cgi-bin/lib/myfile.pl line 25.