文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>读取外部 perl 代码作为配置文件的模式

读取外部 perl 代码作为配置文件的模式

时间:2008-08-15  来源:hellwolf

package HWTAG::Config;
# default configurations
my %config_default = (
category => {},
);

# config file should operate on this variable
our %config;

sub load($$) {
my ($config_file, $config) = @_;
%config = %config_default;
unless (my $return = do $config_file) {
die "couldn't parse config file: $@" if $@;
die "couldn't do config file: $!" unless defined $return;
die "couldn't run config file" unless $return;
}

# copy instead of reference for multiple instances of objects having
# different configurations.
%$config = %config;
}

 $config_file ||= $ENV{HWTAG_CONFIG};
$config_file ||= catfile($ENV{HOME}, '.hwtag.pl');

HWTAG::Config::load($config_file, $self->{config});
将里面的 HWTAG 换成其他就可以了,配置文件为 perl 代码,以修改 %config 变量来对程序进行配置,比如:

$config{category} = {
    read => {
        lib => '/data/share/read/.lib',
        export => '/data/share/read',
        post_sync_sub => sub {
            my ($self, $basemeta, $entry, @files) = @_;
        },
    },
};

相关阅读 更多 +
排行榜 更多 +
三角符文第一章下载

三角符文第一章下载

角色扮演 下载
闪客快打3无敌版下载

闪客快打3无敌版下载

飞行射击 下载
嘀嘀动画官方正版下载

嘀嘀动画官方正版下载

趣味娱乐 下载