script/weather.pl untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 102 MC/DCmcdc 0.0% 0 / 39 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 188 CC 7 SCAR 35.9
CC
7
Cov
0%
get_icon
56.0
get_weather
2.0
BEGIN
2.0
CRAP 36.4
1 #!/usr/local/bin/perl
2  
3 use strict;
4 use warnings;
5 use Weather::Fetch;
6  
7 my $w = new Weather::Fetch("F", "60608", "EN", "US", "chicago");
8 my $xml = $w->getXml;
9  
10 sub get_weather {
11 my ($type) = @_;
12 my $temp = $w->getWeather($xml, $type);
13 return $temp;
14 }
15  
16 sub get_icon {
17 my $str;
18  
19 if($_[0] =~ /Sunny/i || $_[0] =~ /Mostly Sunny/i || $_[0] =~ /Partly Sunny/i || $_[0] =~ /Intermittent Clouds/i || $_ [0]=~ /Hazy Sunshine/i ||
20 $_[0] =~ /Hazy Sunshine/i || $_[0] =~ /Hot/i)
21 {
22 $str = "";
23 }
24 elsif($_[0] =~ /Mostly Cloudy/i || $_[0] =~ /Cloudy/i || $_[0] =~ /Dreary (Overcast)/i || $_[0] =~ /Fog/i)
25 {
26 $str = "";
27 }
28 elsif( $_[0] =~ /Showers/i || $_[0] =~ /Mostly Cloudy w\/ Showers/i || $_[0] =~ /Partly Sunny w\/ Showers/i || $_[0] =~ /T-Storms/i ||
29 $_[0] =~ /Mostly Cloudy w\/ T-Storms/i || $_[0] =~ /Partly Sunny w\/ T-Storms/i || $_[0] =~ /Rain/i)
30 {
31 $str = "";
32 }
33 elsif( $_[0] =~ /Windy/i)
34 {
35 $str = "";
36 }
37 elsif($_[0] =~ /Flurries/i || $_[0] =~ /Mostly Cloudy w\/ Flurries/i || $_[0] =~ /Partly Sunny w\/ Flurries/i || $_[0] =~ /Snow/i ||
38 $_[0] =~ /Mostly Cloudy w\/ Snow/i || $_[0] =~ /Ice/i || $_[0] =~ /Sleet/i || $_[0] =~ /Freezing Rain/i || $_[0] =~ /Rain and Snow/i ||
39 $_[0] =~ /Cold/i)
40 {
41 $str = "";
42 }
43 elsif($_[0] =~ /Clear/i || $_[0] =~ /Mostly Clear/i || $_[0] =~ /Partly Cloudy/i || $_[0] =~ /Intermittent Clouds/ ||
44 $_[0] =~ /Hazy Moonlight/i || $_[0] =~ /Mostly Cloudy/i || $_[0] =~ /Partly Cloudy w\/ Showers/i || $_[0] =~ /Mostly Cloudy w\/ Showers/i ||
45 $_[0] =~ /Partly Cloudy w\/ T-Storms/i || $_[0] =~ /Mostly Cloudy w\/ Flurries/i || $_[0] =~ /Mostly Cloudy w\/ Snow/i)
46 {
47 $str = "";
48 }
49 else
50 {
51 $str = "";
52 }
53  
54 return $str;
55 }
56  
57 my $con = get_weather("condition");
58 my $temp = get_weather("temp");
59  
60 print get_icon($con) . " " . $temp . "\n";
61  
62 exit 0;
63  
64 =head1 NAME
65  
66 weather.pl - prints weather
67  
68 =head1 DESCRIPTION
69  
70 A simple Weather script which usually prints Current weather.
71 This distribution is the first time the author has created one.
72  
73 =head1 SYNOPSIS
74  
75 $ weather.pl
76 Sunny 14C
77  
78 =head1 AUTHOR
79  
80 Brad Heffernan
81  
82 =head1 LICENSE
83  
84 FreeBSD
85  
86 =head1 INSTALLATION
87  
88 Using C<cpan>:
89  
90 $ cpan Weather::Fetch
91  
92 Manual install:
93  
94 $ perl Makefile.PL
95 $ make
96 $ make install
97  
98 =cut