in reply to Key, newline, value problem

Well, you can get the value with simple flagging. This should be ok (untested).
while (<>) { if ($key) { m/(\d+)/ $hash{$key}=$1; $key=""; } elsif (/(\S+)\s+(\d+)/) { $hash{$1}=$2 } else { m/(\s+)/ $key=$1; } }