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...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 9th of Feb 2010 07:08:29 AM Download | Raw | Embed | Report
  1. #!/usr/bin/perl
  2. # du har mail, du har mail, du har mail
  3. # det plingar till, du kan svara om du vill
  4. use strict;
  5. use warnings;
  6. use encoding 'utf8';
  7. use Weather::Google;
  8. use Getopt::Long;
  9.  
  10. # fucking options here
  11. our $irc;
  12. GetOptions(
  13.     'irc'   => \$irc,
  14. );
  15.  
  16. my $city;
  17. if(@ARGV) { # where to look?
  18.     $city = $ARGV[0];
  19. }
  20. else {
  21.     $city = 'norrköping';
  22. }
  23.  
  24. my $gw = Weather::Google->new($city); #weather object
  25.  
  26. my @info = ($gw->current_conditions( #current conditions for $city
  27.                                     'temp_c',
  28.                                     'wind_condition',
  29.                                     'humidity',
  30.                                     'condition',
  31.                                 ));
  32.  
  33. foreach(@info) {
  34.     if(!defined) {
  35.         print "$0: undefined vars; learn to spell kkthx\n";
  36.         exit 1;
  37.     }
  38. }
  39.  
  40. sub irc {
  41.     print "· ".ucfirst($city),": $info[0]°C [$info[3]] | $info[1] | $info[2]\n";
  42. }
  43.  
  44. # fucking do not forget to let getopt do its work first and then, later on,
  45. # check if $foo_option is def or not, and THEN call the sub. Otherwise you'll
  46. # be sitting there again smoking 2 packs of cigs trying to figure out why the
  47. # fuck your vars are uninitialized.
  48. if($irc) {
  49.     irc();
  50. }
  51. else {
  52.     main_f();
  53. }
  54.  
  55. # main formatting
  56. sub main_f {
  57.     printf("%0s\n\n %-0s\n %0s\n %0s\n %0s\n",
  58.             '· '.ucfirst($city)." Today:",
  59.             '· '.'Temperature: '.$info[0]."°C",
  60.             '· '.'Condition: '.$info[3],
  61.             '· '.$info[1],
  62.             '· '.$info[2],
  63.         );
  64. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: