私はIPアドレスのリストを返す関数を書いています。入力として配列の値を渡す
私のテストスクリプトdns.pl
から関数を呼び出し、for
ループを使用して、一度に1つのアドレスをコマンドの入力として渡します。
スクリプトのコマンドに1つのIPアドレス以外のすべてを一度に入力として(一度に)渡したいとします。
アドレスが= x.x.x.xと一致するかどうかを確認します。その場合は、そのアドレスをスキップして、他のアドレスをスクリプトの下のコマンドの入力として渡します。
# The IP address that are retuned by the function should be passed here as input all at once. Except one ip address
./dns.pl -t ipaddress1,ip address2,.... ipadress,n -f .5 -S C
# function call to get the list of ip addresses
$self->{'machine_ip'} = $self->{'queryObj'}->get_machine_ip($self->{'vip_owner'});
# Currently, I'm passing one ip address at a time using foreach
# But, I want to pass all but one ip address all at once to the below command as input.
foreach my $ip (@{ $self->{'machine_ip'} }) {
$self->{'exec_obj'}->execute(./dns.pl -t ipaddress1,ip address2,.... ipadress,n -f .5 -S C);
}
sub get_machine_ip {
my ($self, $vip_owner) = @_;
my @ip =();
my $sql_query = $self->{queryObj}->execute("select machineIP from sripd_peer_Status where frontend=$vip_owner");
my $records = $self->{queryObj}->result();
foreach my $row (@$records) {
push @ip, $row->{machineIP};
}
return \@ip;
}
あなたは、 'perl'のコメントのコメントに対して' // 'は動作しないことに気付きますか? – Sobrique