#!/usr/bin/perl
use strict;
use Geo::WeatherNOAA;
use CGI qw(param);
my $OK_CHARS = "-a-zA-Z0-9_.@'\"\s";
foreach (param()) {
# sanitize data input from form
if (param($_) =~ /[^$OK_CHARS]/) {
print "Content-type: text/html\n\n";
print "
Form ErrorWarning: One of the characters in your form entry is not allowed by this program. Characters that are allowed are A-Za-z0-9.@-\"'. Please hit back on your browser and try again.";
exit(0);
}
}
my ($city, $state);
if (param("city")) {
$city = param("city");
} else {
$city = "Minneapolis";
}
if (param("state")) {
$state = param("state");
} else {
$state = "MN";
}
print "Content-type: text/html\n\n";
print <BenWorld
EOHTML
print "
Weather Forecast for $city, $state
";
my $html_weather_table = get_weather_data($city,$state);
print $html_weather_table;
print "