use Getopt::Std; my %opts; getopts( 'dhc:', \%opts ); # usw, -c for cfg-file $opts{'c'} and $opts{'c'} !~ m{^/([\w\.]+/)*[\w\.]+$} and &usage; my $cfg = $opts{'c'} ? $opts{'c'} : '/default/path/to.conf'; open CFG, '<'.$cfg or die; while() { # do sth like ... /^\s*(.*?)\s*: (.*)$/; $cfg{ $1 } = $2; } foreach (keys %cfg) { $opts{$_} and $cfg{$_} = $opts{$_}; }