Subdomain Posts
Perl | 2 hours ago
Perl | 2 hours ago
Perl | 4 hours ago
Perl | 14 hours ago
Perl | 14 hours ago
Perl | 17 hours ago
Perl | 17 hours ago
Perl | 1 day ago
Perl | 1 day ago
Perl | 1 day ago
Recent Posts
None | 17 sec ago
None | 49 sec ago
C | 1 min ago
C | 1 min ago
Java 5 | 1 min ago
None | 2 min ago
None | 3 min ago
None | 3 min ago
None | 4 min ago
None | 4 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By Anonymous on the 9th of Feb 2010 07:08:29 AM
Download |
Raw |
Embed |
Report
#!/usr/bin/perl
# du har mail, du har mail, du har mail
# det plingar till, du kan svara om du vill
use strict;
use warnings;
use encoding 'utf8';
use Weather::Google;
use Getopt::Long;
# fucking options here
our $irc;
GetOptions(
'irc' => \$irc,
);
my $city;
if(@ARGV) { # where to look?
$city = $ARGV[0];
}
else {
$city = 'norrköping';
}
my $gw = Weather::Google->new($city); #weather object
my @info = ($gw->current_conditions( #current conditions for $city
'temp_c',
'wind_condition',
'humidity',
'condition',
));
foreach(@info) {
print "$0: undefined vars; learn to spell kkthx\n";
}
}
sub irc {
print "· ".ucfirst($city),": $info[0]°C [$info[3]] | $info[1] | $info[2]\n";
}
# fucking do not forget to let getopt do its work first and then, later on,
# check if $foo_option is def or not, and THEN call the sub. Otherwise you'll
# be sitting there again smoking 2 packs of cigs trying to figure out why the
# fuck your vars are uninitialized.
if($irc) {
irc();
}
else {
main_f();
}
# main formatting
sub main_f {
printf("%0s\n\n %-0s\n %0s\n %0s\n %0s\n",
'· '.'Temperature: '.$info[0]."°C",
'· '.'Condition: '.$info[3],
'· '.$info[1],
'· '.$info[2],
);
}
Submit a correction or amendment below.
Make A New Post