#! /usr/bin/perl # # displayWeather.cgi # # Reads most recent outside temperature record from the weather database # and generates a little HTML on stdout with that value embedded in it. # # For more information about: # # Postgres generally www.postgresql.org # Postgres' dialect of SQL "man sql" # psql, the interactive query tool "man psql" # The select statement "man select" # To connect to the weather database using psql "psql -d weather" # (when logged-in to quark as weather) # Perl5 extension for Postgres "perldoc Pg" # # Who When What # ---------------------------------------------------------------------- # charliep 07-Jan-2000 Created. # use Pg; use strict; my $connection; my $sql; my $result; my $timestamp; my $out_temperature; my $WebData = "WebData.dat"; my @fields; print "Content-Type: text/html\n\n"; open(INPUT, $WebData); while() { @fields=split(/ /); $out_temperature=shift(@fields); foreach(@fields){ $timestamp.="$_ "; } } close(INPUT); print"It's currently $out_temperature C on the roof of our home in Dennis ($timestamp)"; exit 0;