オプション > コンフィグ > デフォルト値の優先順位で設定

メモ。

#! /opt/local/bin/perl
use strict;
use warnings;

use Getopt::Long;
use Config::Simple;

my %option = (
    hoge => '',
);
Config::Simple->import_from("$ENV{HOME}/.testconfig" ,\%option);
GetOptions(
    'hoge=s' => \$option{hoge},
);


print <<"EOF";
hoge      @{[ $option{hoge} || "default_hoge_value"  ]}
EOF