package MyScript; use Common; @ISA = qw(Common); #公開したいサブルーチン #@EXPORT = qw(DelSpace Reduce01 MakePath RegExpQuote); use strict; use File::Path; use File::Basename; use File::Find; use Utils; #=============================================== # デバッグ関係変数 #=============================================== my $Debug = 0; #=============================================== # 文字コード関係変数 #=============================================== # sjis, euc, jis, noconv, utf8 my $FileSystemCharCode = Deps::FileSystemCharCode(); my $FileCharCode = Deps::FileCharCode(); my $PerlCharCode = Deps::PerlCharCode(); my $MySQLCharCode = Deps::MySQLCharCode(); my $WebCharCode = Deps::WebCharCode(); my $WebCharSet = Deps::WebCharSet(); #=============================================== # スクリプト大域変数 #=============================================== my $LF = Deps::LF(); my $DirectorySeparator = Deps::DirectorySeparator(); my $OS = Deps::OS(); #=============================================== # パス(読み込みDB) #=============================================== sub ConvertCommand { my ($cmd) = @_; #print "cmd: $cmd\n"; my $convcmd = ''; my ($head, $doller, $cnext, $residual, $curresidual); $curresidual = $cmd; while(1) { ($head, $doller, $cnext, $residual) = ($curresidual =~ /^(.*?)(\$)(.)(.*)$/); unless(defined $head) { $convcmd = $convcmd . $curresidual; #print "ConvCmd: $convcmd\n"; last; } #print "[$head][$doller][$cnext][$residual]\n"; $curresidual = $residual; if($cnext eq '(') { #$(env_var) 環境変数 env_var の内容を展開する。 my ($envvar, $res) = ($residual =~ /^(.*?)\)(.*)$/); unless(defined $envvar) { $convcmd = $convcmd . $head . $doller . $cnext . $residual; last; } #print "Env: $envvar\n"; my $e = $ENV{$envvar}; $e = '' unless(defined $e); $convcmd = $convcmd . $head . $e; $curresidual = $res; next; } else { if($cnext eq '$') { $convcmd = $convcmd . $head . '$'; next; } elsif($cnext eq 'n') { #$n 改行。メッセージなどを複数行にする時に使う。 $convcmd .= $head . "\n"; next; } else { $convcmd .= $head . $ENV{$cnext}; next; #$e $eがコマンド列中にあると、$eを引数各々に対して$eを置き換え、 } } $convcmd = $convcmd . $head . $doller . $cnext; } #print "ConvCmd: $convcmd\n"; return $convcmd; } BEGIN { } sub new { my ($module, $path) = @_; my $this = {}; bless $this; return $this; } sub DESTROY { my $this = shift; } 1;