How to execute shell command in a perl script?
https://stackoverflow.com/questions/3200801/how-can-i-call-a-shell-command-in-my-perl-script/21153038
1. 用`` 不显示执行结果
my $files = `ls -la`— captures the output of the command in$files
2. 用system or exec 不显示执行结果
system "touch ~/foo"— if you don't want to capture the command's outputexec "vim ~/foo"— if you don't want to return to the script after executing the command
3.用open 适合命令里有管道符时
open(my $file, '|-', "grep foo"); print $file "foo\nbar"— if you want to pipe input into
好的心态+正确的方法
浙公网安备 33010602011771号