如何在perl脚本中多次运行perl脚本
以下是我正在使用的骨架脚本:如何在perl脚本中多次运行perl脚本,perl,Perl,以下是我正在使用的骨架脚本: #!/usr/bin/env perl =head1 NAME webapp-1 harness - webapp-1 test =head1 SYNOPSIS webapp-1 [OPTION] -v, --verbose use verbose mode --help print this help message Where OPTION is an integer governing the number
#!/usr/bin/env perl
=head1 NAME
webapp-1 harness - webapp-1 test
=head1 SYNOPSIS
webapp-1 [OPTION]
-v, --verbose use verbose mode
--help print this help message
Where OPTION is an integer governing the number of times the script should be run
Examples:
webapp-1 10
=head1 DESCRIPTION
This is test harness to verify jira issue WEBAPP-1
=head1 AUTHOR
skahmed@mmm.com
=cut
use strict;
use warnings;
use Getopt::Long qw(:config auto_help);
use Pod::Usage;
my $count = $ARGV;
main();
sub main {
# Argument parsing
my $verbose;
GetOptions(
'verbose' => \$verbose,
) or pod2usage(1);
pod2usage(1)unless @ARGV;
while ($count) {
printf "$count \n";
# Here i want to run a perl script N number of times, with N being the ARGV to this command
# capture( [0,1,2, $^X, "yourscript.pl", @ARGS );
$count++;
}
}
我也不能使用IPC::System,因为我无法在运行它的主机(ubuntu 12.04)上安装它。
我试图做的是开发一个perl测试工具,它将运行perl脚本来运行进程、监视数据库表等,我还可以根据执行这些脚本的结果来控制这些脚本的计时
一种可能的解决方案:基于@ARGV多次运行脚本
foreach (1..$ARGV[0])
{
print "hello \n";
}
安装Cpan模块不需要root priv
cpanm
使用-l
选项安装到指定目录中,例如~/perl5/
下
然后在您的程序中使用local::lib
模块将perl
定向到您安装模块的位置。这很简单:
use local::lib '~/project/lib';
或者,如果选择~/perl5/
安装到,只需:
use local::lib;
CpanMinus和local::lib
都可以作为非根目录启动安装:
- CpanMinus
:local::lib
这些功能一起为您提供了Cpan的强大功能,而无需服务器系统管理员的帮助。请看一看:您能否澄清安装模块的困难所在?也许我们可以克服这一点。
IPC::System
也是它的确切名称吗?当@Smylers的IPC::System::Simple使用cpanminus时,不会出现该名称的模块。如果我使用cpanminus,我将必须是root用户或具有root权限才能安装该模块,而我无法从sysops获得该模块。我想我是通过使用System($^X,“hello.pl”,@ARGV)解决了这个问题的,因为父脚本的参数正用于子脚本。现在,我必须弄清楚如何在@ARGV下运行它的次数你绑定了吗?我没有访问cpanm的权限(刚刚学习),当我尝试在本地安装时,我得到lib/perl5/5.8.8/CPAN/Config.pm是不可写的,error@kamal您可以使用wget-O-在本地安装cpanm
http://cpanmin.us |perl----自我升级-l