Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找类似这样require "peacefullscript.pl -whiteflag";的问题,这个问题不起作用。我想要的是调用带有一些标志的脚本并将它创建的全局变量放入当前脚本中。
require "peacefullscript.pl -whiteflag";
我怎样才能轻松做到这一点?
{ local @ARGV = ("-whiteflag"); do "peacefullscript.pl"; }
该local关键字创建一个临时副本@ARGV,不会覆盖您的原始命令行参数。
local
@ARGV
@ARGV = ("-whiteflag"); require "peacefullscript.pl";