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 $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});