環境変数で設定を切り替える
Config::ENVモジュールを使います。
# MyApp/Config.pm
package MyApp::Config;
use strict;
use warnings;
use Config::ENV 'APP_ENV', export => 'config';;
config default => +{
key1 => 'default_value',
};
config test => +{ # 環境変数APP_ENVがtestの場合に有効
key1 => 'test_value',
};
config production => +{ # 環境変数APP_ENVがproductionの場合に有効
key1 => 'production_value',
};
1;
use strict;
use warnings;
use v5.10;
use MyApp::Config;
say config->param("key1");
