简体   繁体   English

如果您已经准备好一个Perl脚本(在Windows中),从命令行运行100次并收集其产生的数据的最佳方法是什么?

[英]if you have a perl script ready (in windows), what's the best way to run it from command line 100 times say and collect the data it produces?

I have written a perl script in Windows, which produces a line or two of output. 我已经在Windows中编写了一个perl脚本,该脚本会产生一两行输出。

I'd like to be able to run the script n=100 times over, say, from the command line without doing more coding in the script (unless there's an easy way to do that) and collect the output? 我希望能够从命令行运行脚本n = 100次,而无需在脚本中进行更多编码(除非有简单的方法可以执行此操作)并收集输出? I've been suggested a batch file might be in order? 有人建议我可能要按顺序处理批处理文件?

Basically, is there an easy way to: 基本上,有一种简单的方法可以:

[perl script.pl >> output + [Enter Key]] # n times in cmd

Thanks! 谢谢!

您可以在批处理文件中使用FOR循环:

for /L %%N IN (1, 1, 100) DO perl script.pl >> output.txt

Just wrap a for loop around your code: 只需在代码周围包裹一个for循环即可:

#!/your/perl

for ( my $i = 0; $i < 100; $i++ ) {
    # YOUR ORIGINAL PERL CODE HERE
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Perl脚本中处理命令行参数的正确方法是什么? - What's the correct way to handle command line arguments in Perl script? 在 Windows 平台上超时从 perl 运行 gradle 的最佳方法是什么? - What is the best way to run gradle from perl with a timeout on a Windows platform? 从命令行运行特定的Perl脚本 - run specific perl script from command line 从命令行将数据传递到perl脚本中 - Passing data into perl script from command line 在 Perl 中让两个模块相互使用功能的最佳方法是什么? - What's the best way to have two modules which use functions from one another in Perl? 从带有 2 个条目的 Windows 命令行执行 Perl 脚本 - Executing Perl script from windows-command line with 2 entry 从weblogic Java EE应用程序运行Perl脚本的最佳方法 - Best way to run a Perl script from weblogic Java EE application 计划任务以从命令行运行 perl 脚本 - schedule task to run perl script from command line 在 Perl 中制作数据结构的深层副本的最佳方法是什么? - What's the best way to make a deep copy of a data structure in Perl? Perl:从Perl脚本中运行Perl脚本的最快方法是什么? - Perl: What is the fastest way to run a perl script from within a perl script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM