CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Passing an input file to my geoip script

 



starchon
New User

Nov 21, 2013, 4:12 AM

Post #1 of 3 (1014 views)
Passing an input file to my geoip script Can't Post

Hi, and thanks in advance for any responses.

I am following the tutorial on Geo::IP at drdobbs website. My code is below:


Code
#!/usr/bin/perl 

use Geo::IP;

my $gip = Geo::IP->new();

while( <> )
{
my( $ip ) = split;

my $country = $gip->country_name_by_addr( $ip );

$Countries{ $country }++;
}

foreach my $ip ( sort keys %Countries )
{
printf "%6d %s\n", $Countries{ $ip }, $ip;
}


When I run the script it just hangs - no output no error messages. It seems to me that I am not passing an input file to the script to split. I am unsure how to do this. ANY advice would be much apreciated.

Starchon


BillKSmith
Veteran

Nov 21, 2013, 5:24 AM

Post #2 of 3 (1010 views)
Re: [starchon] Passing an input file to my geoip script [In reply to] Can't Post

You have not shown us your command to run this script.

When your program appears to hang, it probably is waiting for input from your terminal. Refer to the section of perldoc perlop which discusses the operator <> with a null filehandle. (It should read from a file specified on the command line or STDIN if there is none)
Good Luck,
Bill


starchon
New User

Nov 21, 2013, 7:03 AM

Post #3 of 3 (1003 views)
Re: [BillKSmith] Passing an input file to my geoip script [In reply to] Can't Post

Many thanks - a bit more reading got me there in the end...
Blush

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives