#!/usr/bin/perl use strict; use warnings; use diagnostics; # this makes error messages nicer. use Net::Whois::ARIN; my $file="file_containing_IPs.txt"; open(LIST,$file) or die "Unable to open file $file:$!\n"; my $w = Net::Whois::ARIN->new( host => 'whois.arin.net', port => 43, timeout => 30, ); while() { foreach ($_) { chomp; if(defined $_ && $_) { my @output = $w->network($_); foreach my $net (@output) { printf( "CIDR: %s\tNetName: %s\tNetHandle: %s\n", $net->CIDR, $net->NetName, $net->NetHandle, ); } } } } close(LIST);