-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)にインストールできないため、IPC::Systemを使用できません。私がやろうとしているのは、perlスクリプトを実行してプロセスを実行したり、データベーステーブルを監視したりする、perlテストハーネスを開発することです。また、実行結果に基づいて、これらのスクリプトのタイミングを制御することもできます。

考えられる解決策の1つ:@ARGVに基づいてスクリプトをN回実行する場合

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

1 に答える 1

1

Cpan モジュールをインストールするのにルート権限は必要ありません。

cpanm-lの下など、指定したディレクトリにインストールするためのオプションを取ります~/perl5/

次に、プログラムでモジュールを使用して、local::libモジュールをperlインストールした場所に移動します。これは次のように簡単です。

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

~/perl5/または、インストール先を選択した場合は、次のようにします。

use local::lib;

CpanMinus と両方ともlocal::lib、非ルートとしてブートストラップ インストールできます。

これらを組み合わせることで、サーバーのシステム管理者の支援を必要とせずに Cpan の機能を利用できます。

于 2013-01-08T20:58:42.820 に答える