CIS 2279 Homework Assignment #14
Due Tue Dec 13, 2016 16:45
Create a perl script named lab14.pl. The script needs to have the
following features:(10 points each)
- Prompt the user to enter a date (year, month and day) to
retrieve LSC weather observations.
- If no date is entered, it will determine the current date and
use that as the request date.
- Retrieve station observation data from
http://apollo.lsc.vsc.edu/cgi-bin/logger.pl and storing the data
to a file. Retrieving the data should be done with the
wget
command (see examples below)
- Read through the downloaded file and build a summary of the
data for the day which should include the following: high
temperature, low temperature, average temperature, highest wind
speed, and total precipitation.
- Print the calculated summary data to the screen for the requested date.
Print all temperature values in both Celcius and Farenheit. Print
the times that all highs and lows occurred.
- NOTE: Date for a given date may be requested by specifying
parameters on the URL. Example for requesting data for Dec 1,
2008:
wget -q -O loggerdata.csv http://apollo.lsc.vsc.edu/cgi-bin/logger.pl?year=2008&jday=336
- A good perl example:
$datafile = 'loggerdata.csv';
$url = 'http://apollo.lsc.vsc.edu/cgi-bin/logger.pl\?year='.$year.'\&jday='.$jday;
system("wget -q -O $datafile $url");
or
@output = `wget -q -O - $url`;
There are other approaches to this...
- Note the back-slashes before the ? and & characters along with the
use of single quotes used when defining the value for $url.
last updated: 08 Dec 2016 18:03