sub pack_ip4 { pack 'C4', split /\./, @_ ? $_[0] : $_ } for ( map substr($_, 4), sort map pack_ip4($_).$_, keys %host_result ) { ... }