使用散列的Perl解析器
我是perl新手,对数据结构不是很在行。我一直在开发一个文本解析器,从文本文件中提取信息并将其存储在数据库中。规则模式现在可以了,但我刚刚注意到,我用于哈希“Time”的键不是唯一的,因为有多个更新(在文本文件中)可能同时发生。散列所做的是创建对我来说不可接受的重复项。所以我想再加一把钥匙,也许是一个独特的计数器,但我不知道该怎么做。因此,我尝试添加另一个键“{$recordcnt}”作为计数器,您将看到它附加在所有哈希语句上。我删除了计数器增量语句(可能我没有正确实现) 另外,如果您查看我的代码的print语句块(最后一部分),我试图打印一个数组(@nodes\u and\u index)值,该值包含两列节点和索引,打印并以不同方式显示它们。但是,它不会打印所需的结果。测试假设我想将数据单独输入数据库 那么,我是否将“{$recordcnt}”放错了位置,如果是这样的话。如何使散列中的每个条目随时间而唯一?谢谢你的阅读 这是我的数据示例:使用散列的Perl解析器,perl,perl-data-structures,Perl,Perl Data Structures,我是perl新手,对数据结构不是很在行。我一直在开发一个文本解析器,从文本文件中提取信息并将其存储在数据库中。规则模式现在可以了,但我刚刚注意到,我用于哈希“Time”的键不是唯一的,因为有多个更新(在文本文件中)可能同时发生。散列所做的是创建对我来说不可接受的重复项。所以我想再加一把钥匙,也许是一个独特的计数器,但我不知道该怎么做。因此,我尝试添加另一个键“{$recordcnt}”作为计数器,您将看到它附加在所有哈希语句上。我删除了计数器增量语句(可能我没有正确实现) 另外,如果您查看我的代
TIME: 11/01/13 14:30:24
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 14835 1286 577 4097 2841 14735 9486 573 10633 4488
NEXT_HOP: 10.255.9.126
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:24
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 14835 4758 2379 10721 10787 7830 17777 4875 4488
NEXT_HOP: 10.255.9.126
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:25
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 14835 4758 2379 10721 10787 7830 17777 16480 9486 573 10633 4488
NEXT_HOP: 10.255.9.126
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:25
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 19602 3252 3665 2315 2379 10721 7311 12934 4875 4488
NEXT_HOP: 10.255.9.125
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:34
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 19602 3252 3665 2315 2379 3725
NEXT_HOP: 10.255.9.125
ANNOUNCE
10.44.193.0/24
#!/usr/bin/perl -w
use strict;
use warnings;
my %hash;
my $Dir = "/root/updates/processed/";
my $exit = 0;
my $recordcnt = 0 ;
opendir(DIRECTORY, $Dir) or die $!;
while (my $file = readdir(DIRECTORY)) {
unless ($file=~/\.hr$/){next;}
my $file = $Dir."/".$file;
print "$file\n";
open (IN, $file) or die "error reading file: ", $file,"\n";
my $record_id = "";
#my $recordcnt = 0 ;
my $type = "";
my $peer_ip = "";
my $peer_as = "";
my $local_ip = "";
my $local_as = "";
my $next_hop = "";
my @nodes_and_index = ();
my @withdraw_prefix = ();
my @announce_prefix = ();
while (<IN>) {
#$exit++; last if ($exit==5);
if (/^TIME/) {
if ($type) {$hash{$record_id}{$recordcnt}{'type'} = $type;}
if ($peer_ip) {$hash{$record_id}{$recordcnt}{'peer_ip'} = $peer_ip;}
if ($peer_as) {$hash{$record_id}{$recordcnt}{'peer_as'} = $peer_as;}
if ($local_ip) {$hash{$record_id}{$recordcnt}{'local_ip'} = $local_ip;}
if ($local_as) {$hash{$record_id}{$recordcnt}{'local_as'} = $local_as;}
if ($next_hop) {$hash{$record_id}{$recordcnt}{'next_hop'} = $next_hop;}
if (@nodes_and_index) {push @{$hash{$record_id}{$recordcnt}{'nodes_and_index'}}, @nodes_and_index;}
if (@withdraw_prefix) {push @{$hash{$record_id}{$recordcnt}{'withdraw_prefix'}}, @withdraw_prefix;}
if (@announce_prefix) {push @{$hash{$record_id}{$recordcnt}{'announce_prefix'}}, @announce_prefix;}
$peer_as = "";
$peer_ip = "";
$type = "";
$local_ip = "";
$local_as = "";
$next_hop = "";
$record_id = "";
$recordcnt = 0;
@nodes_and_index = ();
@withdraw_prefix = ();
@announce_prefix = ();
my @time = split '\s', $_;
$record_id = $time[1]."_".$time[2];
} elsif (/^FROM/) {
my @from_tmp = split '\s', $_;
$peer_ip = $from_tmp[1];
$peer_as = $from_tmp[2];
$peer_as =~ s/AS//;
} elsif (/^TO/) {
my @to_tmp = split '\s', $_;
$local_ip = $to_tmp[1];
$local_as = $to_tmp[2];
$local_as =~ s/AS//;
#print "$local_ip\n";
} elsif (/^ASPATH/) {
my @nodes_tmp = split '\s', $_;
shift @nodes_tmp;
my $index = 0;
foreach my $node (@nodes_tmp) {
$index++;
push @nodes_and_index, ($node , $index);
}
}elsif (/^NEXT_HOP/) {
my @next_hop_tmp = split '\s', $_;
$next_hop = $next_hop_tmp[1];
}elsif (/^WITHDRAW/) {
while (<IN>) {
last if !/^ +/;
@withdraw_prefix, $_ ;
}
}elsif (/^ANNOUNCE/) {
while (<IN>) {
last if !/^ +/;
push @announce_prefix, $_;
}
}
if ($record_id) { # handle last result
$hash{$record_id}{$recordcnt}{'peer_as'} = $peer_as;
$hash{$record_id}{$recordcnt}{'peer_ip'} = $peer_ip;
$hash{$record_id}{$recordcnt}{'local_as'} = $local_as;
$hash{$record_id}{$recordcnt}{'local_ip'} = $local_ip;
$hash{$record_id}{$recordcnt}{'next_hop'} = $next_hop;
push @{$hash{$record_id}{$recordcnt}{'nodes_and_index'}} ,@nodes_and_index;
push @{$hash{$record_id}{$recordcnt}{'withdraw_prefix'}} ,@withdraw_prefix;
push @{$hash{$record_id}{$recordcnt}{'announce_prefix'}} ,@announce_prefix;
}
}
close IN;
}
my @arraystuff;
my @separated;
my @iindex=();
my @ppath=();
foreach (sort keys %hash) {
print $_, "\n";
print "\t $hash{$_}{$recordcnt}{'peer_ip'}\n";
print "\t $hash{$_}{$recordcnt}{'peer_as'}\n";
print "\t $hash{$_}{$recordcnt}{'local_ip'}\n";
print "\t $hash{$_}{$recordcnt}{'local_as'}\n";
print "\t $hash{$_}{$recordcnt}{'next_hop'}\n";
@arraystuff = @{$hash{$_}{$recordcnt}{'nodes_and_index'}};
foreach (@arraystuff) {
@separated = split('\s', $_);
push @iindex, $separated[1];
push @ppath, $separated[0];
print "\t index: @iindex";
print "\t path: @ppath";
}
print "\t node index : @{$hash{$_}{$recordcnt}{'nodes_and_index'}}\n";
print "\t withdraw_prefix: @{$hash{$_}{$recordcnt}{'withdraw_prefix'}}\n";
print "\t announce: @{$hash{$_}{$recordcnt}{'announce_prefix'}}\n";
}
这是我的完整代码:
TIME: 11/01/13 14:30:24
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 14835 1286 577 4097 2841 14735 9486 573 10633 4488
NEXT_HOP: 10.255.9.126
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:24
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 14835 4758 2379 10721 10787 7830 17777 4875 4488
NEXT_HOP: 10.255.9.126
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:25
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 14835 4758 2379 10721 10787 7830 17777 16480 9486 573 10633 4488
NEXT_HOP: 10.255.9.126
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:25
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 19602 3252 3665 2315 2379 10721 7311 12934 4875 4488
NEXT_HOP: 10.255.9.125
ANNOUNCE
10.44.193.0/24
TIME: 11/01/13 14:30:34
FROM: 10.255.9.4 AS172193
TO: 10.255.9.10 AS676767
ASPATH: 172193 19601 19602 3252 3665 2315 2379 3725
NEXT_HOP: 10.255.9.125
ANNOUNCE
10.44.193.0/24
#!/usr/bin/perl -w
use strict;
use warnings;
my %hash;
my $Dir = "/root/updates/processed/";
my $exit = 0;
my $recordcnt = 0 ;
opendir(DIRECTORY, $Dir) or die $!;
while (my $file = readdir(DIRECTORY)) {
unless ($file=~/\.hr$/){next;}
my $file = $Dir."/".$file;
print "$file\n";
open (IN, $file) or die "error reading file: ", $file,"\n";
my $record_id = "";
#my $recordcnt = 0 ;
my $type = "";
my $peer_ip = "";
my $peer_as = "";
my $local_ip = "";
my $local_as = "";
my $next_hop = "";
my @nodes_and_index = ();
my @withdraw_prefix = ();
my @announce_prefix = ();
while (<IN>) {
#$exit++; last if ($exit==5);
if (/^TIME/) {
if ($type) {$hash{$record_id}{$recordcnt}{'type'} = $type;}
if ($peer_ip) {$hash{$record_id}{$recordcnt}{'peer_ip'} = $peer_ip;}
if ($peer_as) {$hash{$record_id}{$recordcnt}{'peer_as'} = $peer_as;}
if ($local_ip) {$hash{$record_id}{$recordcnt}{'local_ip'} = $local_ip;}
if ($local_as) {$hash{$record_id}{$recordcnt}{'local_as'} = $local_as;}
if ($next_hop) {$hash{$record_id}{$recordcnt}{'next_hop'} = $next_hop;}
if (@nodes_and_index) {push @{$hash{$record_id}{$recordcnt}{'nodes_and_index'}}, @nodes_and_index;}
if (@withdraw_prefix) {push @{$hash{$record_id}{$recordcnt}{'withdraw_prefix'}}, @withdraw_prefix;}
if (@announce_prefix) {push @{$hash{$record_id}{$recordcnt}{'announce_prefix'}}, @announce_prefix;}
$peer_as = "";
$peer_ip = "";
$type = "";
$local_ip = "";
$local_as = "";
$next_hop = "";
$record_id = "";
$recordcnt = 0;
@nodes_and_index = ();
@withdraw_prefix = ();
@announce_prefix = ();
my @time = split '\s', $_;
$record_id = $time[1]."_".$time[2];
} elsif (/^FROM/) {
my @from_tmp = split '\s', $_;
$peer_ip = $from_tmp[1];
$peer_as = $from_tmp[2];
$peer_as =~ s/AS//;
} elsif (/^TO/) {
my @to_tmp = split '\s', $_;
$local_ip = $to_tmp[1];
$local_as = $to_tmp[2];
$local_as =~ s/AS//;
#print "$local_ip\n";
} elsif (/^ASPATH/) {
my @nodes_tmp = split '\s', $_;
shift @nodes_tmp;
my $index = 0;
foreach my $node (@nodes_tmp) {
$index++;
push @nodes_and_index, ($node , $index);
}
}elsif (/^NEXT_HOP/) {
my @next_hop_tmp = split '\s', $_;
$next_hop = $next_hop_tmp[1];
}elsif (/^WITHDRAW/) {
while (<IN>) {
last if !/^ +/;
@withdraw_prefix, $_ ;
}
}elsif (/^ANNOUNCE/) {
while (<IN>) {
last if !/^ +/;
push @announce_prefix, $_;
}
}
if ($record_id) { # handle last result
$hash{$record_id}{$recordcnt}{'peer_as'} = $peer_as;
$hash{$record_id}{$recordcnt}{'peer_ip'} = $peer_ip;
$hash{$record_id}{$recordcnt}{'local_as'} = $local_as;
$hash{$record_id}{$recordcnt}{'local_ip'} = $local_ip;
$hash{$record_id}{$recordcnt}{'next_hop'} = $next_hop;
push @{$hash{$record_id}{$recordcnt}{'nodes_and_index'}} ,@nodes_and_index;
push @{$hash{$record_id}{$recordcnt}{'withdraw_prefix'}} ,@withdraw_prefix;
push @{$hash{$record_id}{$recordcnt}{'announce_prefix'}} ,@announce_prefix;
}
}
close IN;
}
my @arraystuff;
my @separated;
my @iindex=();
my @ppath=();
foreach (sort keys %hash) {
print $_, "\n";
print "\t $hash{$_}{$recordcnt}{'peer_ip'}\n";
print "\t $hash{$_}{$recordcnt}{'peer_as'}\n";
print "\t $hash{$_}{$recordcnt}{'local_ip'}\n";
print "\t $hash{$_}{$recordcnt}{'local_as'}\n";
print "\t $hash{$_}{$recordcnt}{'next_hop'}\n";
@arraystuff = @{$hash{$_}{$recordcnt}{'nodes_and_index'}};
foreach (@arraystuff) {
@separated = split('\s', $_);
push @iindex, $separated[1];
push @ppath, $separated[0];
print "\t index: @iindex";
print "\t path: @ppath";
}
print "\t node index : @{$hash{$_}{$recordcnt}{'nodes_and_index'}}\n";
print "\t withdraw_prefix: @{$hash{$_}{$recordcnt}{'withdraw_prefix'}}\n";
print "\t announce: @{$hash{$_}{$recordcnt}{'announce_prefix'}}\n";
}
#/usr/bin/perl-w
严格使用;
使用警告;
我的%hash;
my$Dir=“/root/updates/processed/”;
我的$exit=0;
我的$recordcnt=0;
opendir(目录,$Dir)或die$!;
而(my$file=readdir(DIRECTORY)){
除非($file=~/\.hr$/){next;}
my$file=$Dir.“/”$file;
打印“$file\n”;
打开(在$file中)或死亡“读取文件时出错:”,$file“,\n”;
我的$record_id=“”;
#我的$recordcnt=0;
我的$type=“”;
我的$peer_ip=“”;
我的$peer_as=“”;
我的$local_ip=“”;
我的$local_as=“”;
我的$next_-hop=“”;
我的@nodes_和_索引=();
我的@draw_前缀=();
我的@annound_前缀=();
而{
#$exit++;最后一个if($exit==5);
如果(/^TIME/){
如果($type){$hash{$record_id}{$recordcnt}{'type'}=$type;}
如果($peer_ip){$hash{$record_id}{$recordcnt}{'peer_ip'}=$peer_ip;}
if($peer_-as){$hash{$record_-id}{$recordcnt}{'peer_-as'}=$peer_-as;}
如果($local_ip){$hash{$record_id}{$recordcnt}{'local_ip'}=$local_ip;}
if($local_-as){$hash{$record_-id}{$recordcnt}{'local_-as'}=$local_-as;}
如果($next_-hop){$hash{$record_-id}{$recordcnt}{'next_-hop'}=$next_-hop;}
如果(@nodes_和_index){push@{$hash{$record_id}{$recordcnt}{'nodes_和_index'}},@nodes_和_index;}
如果(@draw_prefix){push@{$hash{$record_id}{$recordcnt}{'draw_prefix'}},@draw_prefix;}
如果(@annound_prefix){push@{$hash{$record_id}{$recordcnt}{'annound_prefix'}},@annound_prefix;}
$peer_as=“”;
$peer_ip=“”;
$type=“”;
$local_ip=“”;
$local_as=“”;
$next_-hop=“”;
$record_id=“”;
$recordcnt=0;
@节点_和_索引=();
@撤回前缀=();
@宣布前缀=();
my@time=split'\s',$;
$record_id=$time[1]。“_”。$time[2];
}elsif(/^FROM/){
my@from\u tmp=split'\s',$;
$peer_ip=$from_tmp[1];
$peer_as=$from_tmp[2];
$peer_as=~s/as/;
}elsif(/^TO/){
my@to\u tmp=split'\s',$;
$local_ip=$to_tmp[1];
$local_as=$to_tmp[2];
$local_as=~s/as/;
#打印“$local\u ip\n”;
}elsif(/^ASPATH/){
my@nodes\u tmp=split'\s',$;
shift@nodes\u tmp;
我的$index=0;
foreach my$node(@nodes\u tmp){
$index++;
推送@nodes_和_索引,($node,$index);
}
}elsif(/^NEXT_-HOP/){
my@next\u hop\u tmp=split'\s',$;
$next_hop=$next_hop_tmp[1];
}elsif(/^draw/){
而{
最后一个如果!/^+/;
@提取前缀,$;
}
}elsif(/^annound/){
而{
最后一个如果!/^+/;
推送@announce\u前缀,$\u;
}
}
如果($record_id){#处理最后的结果
$hash{$record\u id}{$recordcnt}{'peer\u as'}=$peer\u as;
$hash{$record\u id}{$recordcnt}{'peer\u ip'}=$peer\u ip;
$hash{$record_id}{$recordcnt}{'local_as'}=$local_as;
$hash{$record\u id}{$recordcnt}{'local\u ip'}=$local\u ip;
$hash{$record\u id}{$recordcnt}{'next\u hop'}=$next\u hop;
推送{$hash{$record_id}{$recordcnt}{'nodes_和_index'},@nodes_和_index;
push@{$hash{$record\u id}{$recordcnt}{'draw\u prefix'},@draw\u prefix;
push@{$hash{$record\u id}{$recordcnt}{'announce\u prefix'},@announce\u prefix;
}
}
接近;
}
我的@arraystuff;
我的父母分开了;
我的@iindex=();
我的@ppath=();
foreach(排序键%hash){
打印美元“\n”;
打印“\t$hash{$\}{$recordcnt}{'peer\u ip'}\n”;
打印“\t$hash{$\u}{$recordcnt}{'peer\u as'}\n”;
打印“\t$hash{$\}{$recordcnt}{'local\u ip'}\n”;
打印“\t$hash{$\}{$recordcnt}{'local\u as'}\n”;
打印“\t$hash{$\}{$recordcnt}{'next\u hop'}\n”;
@arraystuff=@{$hash{${}{$recordcnt}{'nodes_和_index'};
foreach(@arraystuff){
@分离=分离('\s',$);
推送@iindex,$separated[1];
推送@ppath,$separated[0];
打印“\t索引:@iindex”;
打印“\t路径:@ppath”;
}
打印“\t节点索引:@{$hash{$\u}{$recordcnt}{'nodes\u和\u index'}}\n”;
打印“\t撤消\u前缀:@{$ha”
push @myarray, $tmphash;
$tmphash = {};
foreach my $row (@myarray) {
print "\t $row->{'peer_ip'}\n";
#... and so on
#!/usr/bin/perl -w
use strict;
use warnings;
my @datasetarray;
my $Dir = "/root/updates/processed/";
my $exit = 0;
opendir(DIRECTORY, $Dir) or die $!;
while (my $file = readdir(DIRECTORY)) {
unless ($file=~/\.hr$/){next;}
#unless ($file=~/\.txt$/){next;}
my $file = $Dir."/".$file;
print "$file\n";
open (IN, $file) or die "error reading file: ", $file,"\n";
my $record_id = "";
my $type = "";
my $peer_ip = "";
my $peer_as = "";
my $local_ip = "";
my $local_as = "";
my $next_hop = "";
my @nodes_and_index = ();
my @withdraw_prefix = ();
my @announce_prefix = ();
my $tmphash = {};
while (<IN>) {
#$exit++; last if ($exit==5);
if (/^TIME/) {
if ($type) {$tmphash->{'type'} = $type;}
if ($peer_ip) {$tmphash->{'peer_ip'} = $peer_ip;}
if ($peer_as) {$tmphash->{'peer_as'} = $peer_as;}
if ($local_ip) {$tmphash->{'local_ip'} = $local_ip;}
if ($local_as) {$tmphash->{'local_as'} = $local_as;}
if ($next_hop) {$tmphash->{'next_hop'} = $next_hop;}
if (@nodes_and_index) {push @{$tmphash->{'nodes_and_index'}}, @nodes_and_index;} #~#~
if (@withdraw_prefix) {push @{$tmphash->{'withdraw_prefix'}}, @withdraw_prefix;} #~#~
if (@announce_prefix) {push @{$tmphash->{'announce_prefix'}}, @announce_prefix;} #~#~
if ($record_id) { #~#~
$tmphash->{'time'} = $record_id; #~#~
push @datasetarray, $tmphash;#~#~
$tmphash = {};#~#~
} #~#~
#The three commented lines above provide error, thus i don't know if i am implementing it the right way, since they are array and different from the others.
$peer_as = "";
$peer_ip = "";
$type = "";
$local_ip = "";
$local_as = "";
$next_hop = "";
$record_id = "";
@nodes_and_index = ();
@withdraw_prefix = ();
@announce_prefix = ();
my @time = split '\s', $_;
$record_id = $time[1]."_".$time[2];
} elsif (/^TYPE/) {
my @type_tmp = split '\s', $_;
$type = $type_tmp[1];
} elsif (/^FROM/) {
my @from_tmp = split '\s', $_;
$peer_ip = $from_tmp[1];
$peer_as = $from_tmp[2];
$peer_as =~ s/AS//;
} elsif (/^TO/) {
my @to_tmp = split '\s', $_;
$local_ip = $to_tmp[1];
$local_as = $to_tmp[2];
$local_as =~ s/AS//;
} elsif (/^ASPATH/) {
my @nodes_tmp = split '\s', $_;
shift @nodes_tmp;
my $index = 0;
foreach my $node (@nodes_tmp) {
$index++;
push @nodes_and_index, ($node , $index);
}
}elsif (/^NEXT_HOP/) {
my @next_hop_tmp = split '\s', $_;
$next_hop = $next_hop_tmp[1];
}elsif (/^WITHDRAW/) {
while (<IN>) {
last if !/^ +/;
push @withdraw_prefix, $_ ;
}
}elsif (/^ANNOUNCE/) {
while (<IN>) {
last if !/^ +/;
push @announce_prefix, $_;
}
}
#if ($record_id) { # handle last result #~#~
# push @datasetarray, $tmphash;#~#~
# $tmphash = {};#~#~
# }#~#~
}
close IN;
#insert the last element of the file
if ($type) {$tmphash->{'type'} = $type;} #~#~
if ($peer_ip) {$tmphash->{'peer_ip'} = $peer_ip;} #~#~
if ($peer_as) {$tmphash->{'peer_as'} = $peer_as;} #~#~
if ($local_ip) {$tmphash->{'local_ip'} = $local_ip;} #~#~
if ($local_as) {$tmphash->{'local_as'} = $local_as;} #~#~
if ($next_hop) {$tmphash->{'next_hop'} = $next_hop;} #~#~
if (@nodes_and_index) {push @{$tmphash->{'nodes_and_index'}}, @nodes_and_index;} #~#~
if (@withdraw_prefix) {push @{$tmphash->{'withdraw_prefix'}}, @withdraw_prefix;} #~#~
if (@announce_prefix) {push @{$tmphash->{'announce_prefix'}}, @announce_prefix;} #~#~
if ($record_id) { #~#~
$tmphash->{'time'} = $record_id; #~#~
push @datasetarray, $tmphash;#~#~
$tmphash = {};#~#~
} #~#~
}
foreach my $row (@datasetarray) {
#print $_, "\n"; #Time doesn't get printed #~#~
print "\t $row->{'time'}\n"; #~#~
print "\t $row->{'peer_ip'}\n"; #OK
print "\t $row->{'peer_as'}\n"; #OK
print "\t $row->{'local_ip'}\n"; #OK
print "\t $row->{'local_as'}\n"; #OK
print "\t $row->{'next_hop'}\n"; #OK
#you can print array refs like this, just make a check that they are declared
print "\t @{$row->{'nodes_and_index'}}\n" if ref $row->{'nodes_and_index'} eq 'ARRAY';#~#~
print "\t @{$row->{'withdraw_prefix'}}\n" if ref $row->{'withdraw_prefix'} eq 'ARRAY';#~#~
print "\t @{$row->{'withdraw_prefix'}}\n" if ref $row->{'withdraw_prefix'} eq 'ARRAY';#~#~
}