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