# command line options, including config already gotten from Getopt::Long and stored in %opt # procedural approach -- Config::General also has an OO approach $opt{config} ||= find_file(); my %config; %config = ParseConfig(-ConfigFile => $opt{config}, -AutoTrue => 1) if $opt{config}; # find_file copied and modified from a version found in Config::Auto sub find_file { my $x; my $whoami = basename($0); my $bindir = dirname($0); $whoami =~ s/\.pl$//; for ("${whoami}config", ".${whoami}config", "${whoami}.config", ".${whoami}.config", "${whoami}conf", ".${whoami}conf", "${whoami}.conf", ".${whoami}.conf", "${whoami}rc", ".${whoami}rc") { return $_ if -r $_; return $x if -r ($x=catfile($bindir,$_)); return $x if -r ($x=catfile($ENV{HOME},$_)); return $x if -r ($x=catfile(rootdir(),"etc",$_)); } return undef; }