I use a default location (using FindBin if the default location is the code directory) and a command line argument to change it if needed:
use YAML qw(LoadFile); # my config files are often in YAML
use FindBin qw($Bin); # $Bin gives the code directory
use Getopt::Std; # Getopt::Long is probably better
my %opt;
getopts( 'c:' => \%opt); # -c <config_file>
$opt{c} ||= "$Bin/config.yaml"; # default location
# this is far from perfect, I should really open the file properly,
# slurp it and then use YAML to parse the content
# as it is, if the file exists but cannot be opened the
# error message is a bit ugly...
die "cannot find file config file $opt{c}" unless( -f $opt{c});
my $env= LoadFile( $opt{c});
|