我在Windows上: - /在我的脚本中我有:
$ENV{'Powmig Path'}powermt
Run Code Online (Sandbox Code Playgroud)
那给了我:
C:\Program\ Files\EMC\PowerPath\powermt
Run Code Online (Sandbox Code Playgroud)
如果我做了if(-e $ENV{'Powmig Path'}powermt)它不起作用.
我尝试用一些替换来改变我的路径\ /
我也尝试添加更多双引号,但似乎没有任何工作:-(
例:
#!/usr/bin/perl
use strict;
use warnings;
use File::Spec;
if($^O =~ m/^MSWin32$/){
my $tmp = File::Spec->catdir($ENV{'Powmig Path'}, "powermt");
if(-e "\"$tmp\""){
print "powermt found\n";
}else{
print "No multipathing found \"$tmp\"\n";
}
$tmp =~ s/\\/\//g;
if(-e "\"$tmp\""){
print "powermt found\n";
}else{
print "No multipathing found \"$tmp\"\n";
}
}else{
print "Error: Unknow OS\n";
}
exit;
Run Code Online (Sandbox Code Playgroud)
输出:
C:\Users\sgargasson\Desktop>perl test.pl
No multipathing found "C:\Program Files\EMC\PowerPath\powermt"
No multipathing found …Run Code Online (Sandbox Code Playgroud)