in reply to Having problems with class::struct
You only are saving one host because every time you go through the outer while loop $c gets overwritten with the current host. You need to save each host as you find it.
To loop over the entries you are on the right track with foreach you just need to dereference the arrays, something like this assuming you store your hosts in @Hosts.
foreach my $host (@Hosts) { foreach my $if (@{$host->interface()}) { print $if->mac(), "\n"; print $if->ip(), "\n"; } } #Or for a specific host/interface print $Hosts[0]->interface(0)->mac(), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Having problems with class::struct
by spill (Novice) on Dec 11, 2003 at 21:12 UTC | |
by tedrek (Pilgrim) on Dec 11, 2003 at 21:50 UTC |