#!/usr/bin/perl use strict; use warnings; use Net::IP qw(&ip_inttobin &ip_bintoip); use Benchmark qw/:all/; sub new { my $ip = new Net::IP('217.229.0.134 - 217.229.0.150') or die; my @ips; my $intip=$ip->intip(); while($intip < $ip->last_int()) { $intip++; push(@ips, ip_bintoip(ip_inttobin($intip, $ip->version), $ip->version)); } } sub old { my $ip = new Net::IP('217.229.0.134 - 217.229.0.150') or die; my @ips = (); while ($ip) { push @ips, $ip->ip(); ++$ip; } } my $result = timethese( 500, { 'new' => \&new, 'old' => \&old } );