Reputation: 11
I'm trying to read a file containing IP addresses and then pass them to Geo::IP
to look up their country code, but my code only returns the country code for the last IP in the file.
open(my $in, "<", "ips.txt") or die "can't open the file $!";
my @lines = <$in>;
use Geo::IP;
my $gi = Geo::IP->new(GEOIP_MEMORY_CACHE);
foreach (@lines) {
print $gi->country_code_by_addr($_);
}
What am I doing wrong?
Upvotes: 1
Views: 339