while ( my $ip = $n->next ) { # do something with ip }