我正在尝试将一个Perl脚本从Unix移植到Windows,但由于open函数中不支持forking pipes而几乎无法使其工作。以下是代码:
sub p4_get_file_content {
my $filespec = shift;
return Content placeholder! if ($options{ dry-run });
debug("p4_get_file_content: $filespec
");
local *P4_OUTPUT;
local $/ = undef;
my $pid = open(P4_OUTPUT, "-|");
die "Fork failed: $!" unless defined $pid;
if ($pid == 0) { # child
my $p4 = p4_init();
my $result = undef;
$result = $p4->Run( print , $filespec);
die $p4->Errors() if $p4->ErrorCount();
if (ref $result eq ARRAY ) {
for (my $i = 1; $i < @$result; $i++) {
print $result->[$i];
}
}
$p4->Disconnect();
exit 0;
}
my $content = <P4_OUTPUT>;
close(P4_OUTPUT) or die "Close failed: ($?) $!";
return $content;
}
错误是:
- is not recognized as an internal or external command,
operable program or batch file.
有人知道怎样让这个工作吗?谢谢!
迈克