# untested code... my $config_dir = "/path/to/script/config"; my $config_file = $config_dir . "/" . "config.file"; my %config = read_config($config_file); sub read_config { my $config = shift || die "Config file name not supplied \n"; open(CONFIG, $config) || die "Could not read from $config: $!\n"; # code to parse config file goes here close(CONFIG); return %config; # or @config or .... }