in reply to "Modification of non-creatable array value attempted, subscript -1" Error
As for the problem with your code, I'd bet you have a blank line in your input file. You're not checking $_ (default input), so you'd be feeding an empty string into Net::Whois::ARIN.#!/usr/bin/perl use strict; use warnings; use diagnostics; # this makes error messages nicer.
#!/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(<LIST>) { 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);
|
|---|