in reply to Find config file by traverse directory
use File::Spec qw(); use Path::Class qw(dir file); use File::HomeDir qw(); sub find_config { my $path = dir('.')->absolute; while ($path) { my $file = file($path, 'my.conf'); return $file if -e $file; last if $path eq File::Spec->rootdir; $path = $path->parent; } my $file = file(File::HomeDir->my_home, 'my.conf'); return -e $file ? $file : ''; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Find config file by traverse directory
by Anonymous Monk on Apr 26, 2012 at 11:53 UTC | |
by Anonymous Monk on Apr 26, 2012 at 12:22 UTC |