voj has asked for the wisdom of the Perl Monks concerning the following question:
use File::Spec::Functions;
use File::Basename;
use Cwd;
sub find_config {
my $path = cwd;
while ($path) {
my $file = catfile($path,'my.conf');
return $file if -e $file;
last if $path eq dirname($path);
$path = dirname($path);
}
my ($login) = getpwuid($<);
my $file = catdir('/home',$login,'my.conf');
return -e $file ? $file : '';
}
I was wondering whether there already is a reliable implementation in some CPAN module, that also deals with all these different file systems. I bet my code fails under some unknown special circumstances...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find config file by traverse directory
by Anonymous Monk on Apr 26, 2012 at 10:29 UTC | |
by Anonymous Monk on Apr 26, 2012 at 11:53 UTC | |
by Anonymous Monk on Apr 26, 2012 at 12:22 UTC |