1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as `perl test.pl' 3######################### We start with some black magic to print on failure. 4 5# Change 1..1 below to 1..last_test_to_print . 6# (It may become useful if the test is moved to ./t subdirectory.) 7 8BEGIN { $| = 1; print "1..2\n"; } 9END {print "not ok 1\n" unless $loaded;} 10use Geo::Weather; 11$loaded = 1; 12print "ok 1\n"; 13 14######################### End of black magic. 15 16$weather = new Geo::Weather; 17$weather->{timeout} = 10; 18$weather->{debug} = 2; # Adjust debug level 19 20print "Enter city of location you are at: "; 21my $city = <STDIN>; 22chomp($city); 23 24print "Enter state of location you are at: "; 25my $state = <STDIN>; 26chomp($state); 27 28print "Proxy (just press enter if no proxy): "; 29my $proxy = <STDIN>; 30chomp($proxy); 31$weather->{proxy} = $proxy; 32 33if ($proxy) { 34 unless ($ENV{HTTP_PROXY_USER}) { 35 print "Proxy Username: "; 36 my $proxy_user = <STDIN>; 37 chomp($proxy_user); 38 $weather->{proxy_user} = $proxy_user; 39 } 40 41 unless ($ENV{HTTP_PROXY_PASS}) { 42 print "Proxy Password: "; 43 my $proxy_pass = <STDIN>; 44 chomp($proxy_pass); 45 $weather->{proxy_pass} = $proxy_pass; 46 } 47} 48 49 50print "Attempting to connect to weather.com...\n\n"; 51 52my $condition = $weather->get_weather($city, $state); 53 54if (ref $condition) { 55 print "Current Conditions for $condition->{city}, $condition->{state}:\n\n"; 56 print " Condition: $condition->{cond}\n"; 57 print " Condition Image: $condition->{pic}\n"; 58 print " Temp: $condition->{temp} F\n"; 59 print " Temp: $condition->{temp_c} C\n"; 60 print " Wind: $condition->{wind}\n"; 61 print " Heat Index: $condition->{heat} F\n"; 62 print " Visability: $condition->{visb}\n"; 63 print " Barometer: $condition->{baro}\n\n"; 64 print "If the above results are correct, your Geo::Weather installation is functioning normally\n"; 65 print "ok 2\n"; 66} else { 67 print "Error: $condition\n"; 68 print "not ok 2\n"; 69} 70