【发布时间】:2011-09-26 12:32:08
【问题描述】:
我有这个数据集 - 我只关心类 id,process@server: 我正在尝试将所有三个加载到多级哈希中。
class_id: 995 (OCAive ) ack_type: NOACK supercede: NO copy: NO bdcst: NO
PID SENDS RECEIVES RETRANSMITS TIMEOUTS MEAN S.D. #
21881 (rocksrvr@ith111 ) 1 1 0 0
24519 (miclogUS@ith110 ) 1 1 0 0
26163 (gkoopsrvr@itb101 ) 1 1 0 0
28069 (sitetic@ith100 ) 23 4 0 0
28144 (srtic@ithb10 ) 33 5 0 0
29931 (loick@ithbsv115 ) 1 1 0 0
87331 (rrrrv_us@ith102 ) 1 1 0 0
---------- ---------- ---------- ---------- ------- ------- ------
61 14 0 0
当我尝试填充哈希时,它并没有得到太多(数据转储器结果如下)
$VAR1 = '';
$VAR2 = {
'' => undef
};
这是代码:
#!/usr/bin/perl -w
use strict;
my $newcomm_dir = "/home/casper-compaq/work_perl/newcomm";
my $newcomm_file = "newcomm_stat_result.txt";
open NEWCOMM , "$new_comm_dir$newcomm_file";
while (<NEWCOMM>) {
if ($_ =~ /\s+class_id:\s\d+\s+((\w+)\s+)/){
my $message_class = $1;
}
if ($_ =~ /((\w+)\@\w+\s+)/) {
my $process = $1;
}
if ($_ =~ /(\w+\@(\w+)\s+)/) {
my $servers = $1;
}
my $newcomm_stat_hash{$message_class}{$servers}=$process;
use Data::Dumper;
print Dumper (%newcomm_stat_hash);
}
【问题讨论】: