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; }