- 论坛徽章:
- 0
|
use strict;
use warnings;
use Getopt::Long;
my @node = ();
my $nodegroup = "";
my $dir = "/opt/OV/bin/OpC/utils/opcnode";
my $list_Nodes =$dir." "."-list_nodes";
my $list_AssNodes = $dir." "."-list_ass_nodes"." group_name=".$nodegroup;
my %list_AssTempls =();
my %nettype = ();
GetOptions("n|node=s"=>\@node,"ng|nodegroup=s"=>\$nodegroup);
######################################################################
#Get all nodes' nettype and the command that is used to get a node's assigned templates
######################################################################
open(P1,"$list_Nodes|") or die "Can't run the command: $!";
foreach (@node)
{
my $flag = 0;
my $node = $_;
while(<P1>)
{
$flag = 1 if(/$node/i);
if($flag && /Network\sType\s+=\s(\w+)/)
{
$nettype{$node}=$1;
last;
}
}
$list_AssTempls{$node}=$dir." "."-list_ass_templs"." nodename=".$node." nettype=".$nettype{$node};
}
close P1;
比如命令为perl 1.pl -n aaa -ng group
问题就在while(<P1>)这里,在while上一句,print "@node";时,@node都还是aaa,但是进入while循环后@node就变成管道读入的数据了,并且,当我在$nettype{$node}=$1;上一句打印@node的值的时候,@node居然变成了Network Type = NETWORK了,我觉得很奇怪额,@node不是等于参数aaa吗,怎么后面就变了呢 |
|