#! perl -slw use strict; use Time::HiRes qw[ time ]; open IPS, '> 1; seek IPS, $pos*6, 0; ( $ip, $u ) = unpack 'Nn', ; $hi = $pos - 1, next if $ip > $toFind; $lo = $pos + 1, next if $ip < $toFind; return join('.',unpack'C4',pack'N',$ip), $u if $ip == $toFind; } return; } my $start = time; my $found = 0; while( <> ) { chomp; my( $ip, $user ) = find( $_ ); #warn "$_ unassigned\n" and next unless $user; ++$found; printf "%s allocated to user;%u\n", $ip, $user; } my $taken = time() - $start; warn sprintf "%d lookups ($found found) in %.3f seconds (%.6f/sec)\n", $., $taken, $taken / $.;