Linux Tips and Tricks

Linux Tips and Tricks

Find Weather using perl script Weather::Google

August8

Find Weather using perl script Weather::Google

1) Install the Weather::Google using the Synaptic Package Manager (in Ubuntu)

2) copy paste the below code and save it as googleweather.pl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl
use Weather::Google;
 
# If you plan on using locations with non-ASCII characters
use encoding 'utf8';
 
my $gw;
 
## Initialize the module
$gw = new Weather::Google('Singapore'); # City name
 
## Get some current information
 
my @info;
@info = $gw->current('temp_f','temp_c','humidity','wind_condition');
 
## Forecast
 
print "Today's high: ", $gw->forecast(0,'high'),"\n";
print "Today's low: ", $gw->forecast(0,'low'),"\n";
 
## Forecast information:
my $info = $gw->forecast_information;
print "Zip: " . $info->{postal_code}."\n";
 
3) Execute the code using perl googleweather.pl
1
2
3
4
$ perl googleweather.pl
Today's high: 90
Today's low: 77
Zip: Singapore

If you want to install the package in windows then issue the below command in command prompt

1
 ppm install Weather-Google
posted under Uncategorized

Email will not be published

Website example

Your Comment:


Recent Comments

    Categories