For starters, don't use prototypes unless required. In other words, drop the () on the sub line.
It would probably be better to pass the file name as a parameter.
You should localize your file handle.
I see that @lines is not declared either. I don't see any reason for this to be a global. This is probably the reason you're seeing the wrong config file.
sub read_the_config { my ($file) = @_; my @lines; local *CFG; open(CFG, "<$file") || log_error("Problem reading $file - $!"); while (<CFG>) { ... return \@lines; }
In newer version of Perl (don't know which exactly, but <updated>at least since 5.6.1</updated>), you can get rid of the local completely:
sub read_the_config { my ($file) = @_; my @lines; my $cfg_fh; open($cfg_fh, "<$file") || log_error("Problem reading $file - $!"); while (<$cfg_fh>) { ... return \@lines; }
In reply to Re: mod_perl leaking variables?
by ikegami
in thread mod_perl - local vs my...
by smullis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |