in reply to lost in my data structure.

Hi,
Since there are some syntax errors in your Hash array I have modified your Hash array as:
%host = ( 'ip1' => { 'tcp' => { '21' => { 'state' => 'open', 'service' => 'ftp' }, '80' => { 'state' => 'open', 'service' => 'web' } } }, 'ip2' => { 'tcp' => { '23' => { 'state' => 'open', 'service' => 'telnet' }, '80' => { 'state' => 'open', 'service' => 'web' } } } );
You can use reference operator '->' to fetch complex datastructures and the code to display as per your requirement is as follows:
foreach $ip (keys %host) { print $ip . "\n"; foreach $type (keys %{$host{$ip}}) { foreach $no (keys %{$host{$ip}->{$type}}) { print " " . $no . "\t" . $host{$ip}->{$type}->{$no}->{'sta +te'} . "\t" . $host{$ip}->{$type}->{$no}->{'service'} . "\n"; } } }
You can also add 53 open dns to "ip1" as:
$host{'ip1'}->{'tcp'}->{53}->{'state'} = 'open'; $host{'ip1'}->{'tcp'}->{53}->{'service'} = 'dns';
Good Luck,
Hraj

Edited by planetscape - replaced <pre> with <code> tags