【发布时间】:2013-09-02 07:58:37
【问题描述】:
我查看了有关此问题的其他答案,但仍不确定为什么会遇到此问题:在模式匹配中使用未初始化的值 (m//)
my $curr = 0;
my (@up_intf, @nh_ID);
my $line = "";
for (my $index = 0; $index < length(@lines); $index++) {
$line = $lines[$index];
print("The line is: $line");
if (($line =~ /^Group:/i)) {
while (1) {
if (($line =~ /^Uptime:/i)) { last; }
else {
$index++;
$line = $lines[$index];
if (($line =~ /^Downstream/i)) {
$index++;
$line = $lines[$index];
print($line);
$up_intf[$curr] = $line;
}
if (($line =~ /^Next-hop/i)) {
$nh_ID[$curr] = substr($line, 13, ((length($line) - 13)));
print($line);
$curr++;
}
}
}
}
}
谢谢!
【问题讨论】:
-
你认为
$index < length(@lines)是做什么的?另请参阅Loopy Validation ... 长话短说,忘记while(1)。
标签: regex string perl matching