-1

这是我正在使用的骨架脚本:

#!/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 运行脚本 N 次

foreach (1..$ARGV[0])
    {
      print "hello \n";
    }
4

1 回答 1

1

您不需要 root 权限来安装 Cpan 模块。

cpanm接受-l安装到指定目录的选项,例如在~/perl5/.

然后在您的程序中使用local::lib模块指向perl您安装模块的位置。这很简单:

use local::lib '~/project/lib';

或者,如果您选择~/perl5/安装到,只需:

use local::lib;

CpanMinus 和 CpanMinuslocal::lib都可以作为非 root 引导安装:

这些一起为您提供了 Cpan 的强大功能,而无需服务器的系统管理员的帮助。

于 2013-01-08T20:58:42.820 回答