⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.pm

📁 开源MARC数据处理
💻 PM
字号:
#################################################################################	Copyright (C) 2003 Oy Realnode Ab##	This program is free software; you can redistribute it and/or#	modify it under the terms of the GNU General Public License#	as published by the Free Software Foundation; either version 2#	of the License, or (at your option) any later version.##	This program is distributed in the hope that it will be useful,#	but WITHOUT ANY WARRANTY; without even the implied warranty of#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the#	GNU General Public License for more details.##	You should have received a copy of the GNU General Public License#	along with this program; if not, write to the Free Software#	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.###################################################################################   $Id: Config.pm,v 1.3.4.4 2004/01/22 17:47:25 eb Exp $##################################################################################Package declarationpackage lib::Config;# Parses the conf in the same way as conf_parser, however,# returns also to descriptions in the confs to all sections# in the style mysql_desc = <DESCRIPTION> since the MySQL# description is assumed to begin with 'MySQL:'sub conf_parser_advanced{    my $class = shift;    my $T_conf = shift;    my (@T_conf, %conf, $T_all, @T_desc, $T_name);    open T_CONF, "<".$T_conf or die "Cannot open conf: $T_conf\n";	chomp(@T_all = <T_CONF>);	close T_CONF;    push @T_conf, grep /^[a-zA-Z0-9]/, @T_all;    chomp(@T_conf);    foreach (@T_conf)    {        #$_ =~ s/\s//g;        my @T_split = split('=', $_);		$T_split[0] =~ s/\s//g;		$T_split[1] =~ s/^\s*//g;		$T_split[1] =~ s/\s*$//g;        $conf{$T_split[0]} = $T_split[1];    }	$_ = join("\n", @T_all);	while(/<-----(.*?)----->/gs) {		my $T_desc = $1;		$T_desc =~ s/; /;/g;        if($T_desc =~ /;(.+):/g) {			$T_name = $1;		}        $T_desc =~ s/;//g;		$T_name =~ s/ /_/g;        $conf{lc($T_name).'_desc'} = $T_desc."\n";	}    return %conf;}sub save_data{	# Fetch passed arguments	$self = shift;	$conf_in = shift;	$MARCsyn_in = shift;	$conf_out = shift;	$MARCsyn_out = shift;	$backups = shift;	%conf = @_;	# Debug	# print "C_O: $conf_out\n";	# print "M_O: $MARCsyn_out\n";	if(-e $conf_in) {		open C_IN, "<$conf_in";		@C_IN = <C_IN>;		close C_IN;		$C_IN = join("", @C_IN);	}	if(-e $MARCsyn_in) {		open M_IN, "<$MARCsyn_in";		@M_IN = <M_IN>;		close M_IN;		$M_IN = join("", @M_IN);	}	if($backups) {		open C_BCK, ">".$conf_in.".bck";		print C_BCK $C_IN;		close C_BCK;		open M_BCK, ">".$MARCsyn_in.".bck";		print M_BCK $M_IN;		close M_BCK;	}    # Debug	# print "C_IN: $C_IN\n";	# print "M_IN: $M_IN\n";	foreach $key (keys %conf) {		#print "key: $key = $conf{$key}\n";		if($C_IN =~ /$key/) {			#print "CIN\n";			$C_IN =~ s/(\n$key = .*)\n/\n$key = $conf{$key}\n/;		} elsif ($M_IN =~ /^$key/) {			#print "MIN\n";			$M_IN =~ s/(\n$key = .*)\n/\n$key = $conf{$key}\n/;		}	}	open C_OUT, ">$conf_out";	print C_OUT $C_IN;	close C_OUT;	open M_OUT, ">$MARCsyn_out";	print M_OUT $M_IN;	close M_OUT;}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -