#!/usr/bin/perl -w use Class::Struct; my $HostID = "0"; struct Adapter => { ip => '$', mac => '$', }; struct Host => { hostid => '$', hostname => '$', interface => '@', }; while () { s/\r|\n//g; if ( /Host Name.*?:\s*(.*)/ ) { $c = Host->new(); $c->hostid($HostID); $c->hostname($1); printf ("hostid = %s\n", $c->hostid); printf ("hostname = %s\n", $c->hostname); $HostID++; } if ( / adapter/ ) { while () { s/\r|\n//g; if ( /Physical Address.*?:\s*(.*)/ ) { $a=Adapter->new(); $a->mac($1); push @{$c->interface}, $a; printf ("Adapter = %s\n", $c->interface(0)->mac); if ($c->interface(1)) { printf ("Adapter = %s\n", $c->interface(1)->mac); } if ($c->interface(2)) { printf ("Adapter = %s\n", $c->interface(2)->mac); } } if ( /Lease Expires.*?:\s*(.*)/ ) { last; } } }