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

📄 env_conv.pm

📁 HTK应用程序
💻 PM
字号:
;# This sub will convert the HTK environment file in "csh" format
;# 		to "perl" format.
;#
;# Usage: &env_conv::env_convert(HTK_csh_env_file,HTK_perl_env);
;#
;# TL 7/1998
;#

package env_conv;
require Exporter;
@ISA	= qw(Exporter);
@EXPORT	= qw(env_convert);

sub env_convert {

	local ($env_file,$perl_env) = @_;
	open(ENVFILE,"<$env_file") or die "Can't open env $env_file file\n";
	open(PERLENV,">$perl_env") or die "Can't open env $perl_env file\n";
	while(<ENVFILE>) {
		(/^#/ || /^\s+$/) && next;	# skip an empty line or comment
		chop;
		($line, $comment) = split('#',$_);
		$line =~ s/=/ /;	# replace '=' with ' '
		$line =~s/\s+/ /g;			# turn one or more white spaces into a space
		$line =~ s/^ | $//;	# remove ' ' at the end of the line
		($command, $varname, $value ) = split / / ,"$line", 3;
		if ( ($command eq "set") || ($command eq "setenv") ) {
			$value =~ s/\(+//; 
			$value =~ s/\)+//; 
			$value =~ s/\{+//; 
			$value =~ s/\}+//; 
			printf PERLENV '$'."$varname = \"$value\";\n";
		}
		elsif ( $command eq "if" ) {
			printf PERLENV "$command ";
			if ( $varname =~ '$?' ) {
				$varname =~ s/\$\?/defined \$/;
			}
			printf PERLENV "$varname {\n";
		}
		elsif ( $command eq "else" ) {
			printf PERLENV "}\n$command {\n";
		}
		elsif ( $command eq "endif" ) {
			printf PERLENV "}\n";
		}
	}
	
	printf PERLENV "1;\n";
	close(ENVFILE);
	close(PERLENV);
}

1;

⌨️ 快捷键说明

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