Perl等同于PHP的escapeshellarg [英] Perl equivalent of PHP's escapeshellarg
本文介绍了Perl等同于PHP的escapeshellarg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要转义用作外壳程序参数的字符串,我们在PHP
中使用函数escapeshellarg()
. Perl
是否具有等效功能?
To escape the string to be used as shell argument we use the function escapeshellarg()
in PHP
. Does Perl
have an equivalent function ?
推荐答案
String::ShellQuote
,但是在大多数情况下,这是不需要的.您只需避免通过仔细编程即可调用Shell.例如, system
接受参数列表,而不是字符串.
String::ShellQuote
, but most of the time this is not needed. You simply can avoid invoking the shell by careful programming. For example, system
takes a list of arguments instead of a string.
最佳做法:
use IPC::System::Simple qw(systemx);
systemx($command, @arguments);
require IPC::System::Simple;
use autodie qw(:all);
system([@allowed_exit_values], $command, @arguments);
这篇关于Perl等同于PHP的escapeshellarg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文