Perl 修改backticks使用的IO层
i、 e.能够做到Perl 修改backticks使用的IO层,perl,Perl,i、 e.能够做到 $result = `my command`; 使用:raw,:utf8等 是否有我不知道的特殊变量,可以使用的替代方法或模块?我不知道是否有特殊变量,但为什么不使用open()来完成该任务呢?您可以像在文件上一样在管道上指定编码: open(my$cmdin,“-|:raw”,“您的命令”); 我的$result=加入(“”,); 关闭($cmdin); 使用popen: open (my $fd, "-|", $prog, @args) or die "Cou
$result = `my command`;
使用:raw
,:utf8
等
是否有我不知道的特殊变量,可以使用的替代方法或模块?我不知道是否有特殊变量,但为什么不使用open()来完成该任务呢?您可以像在文件上一样在管道上指定编码:
open(my$cmdin,“-|:raw”,“您的命令”);
我的$result=加入(“”,);
关闭($cmdin);
使用popen:
open (my $fd, "-|", $prog, @args)
or die "Couldn't start $prog: $!";
do_whatever($fd);
while (<$fd>) { ... };
open(我的$fd,“-|”,$prog,@args)
或者死亡“无法启动$prog:$!”;
做任何事($fd);
而(){…};
或者如果这还不够,你应该看看它的表亲Open3