#!/usr/bin/perl use diagnostics; use warnings; use strict; use CGI; ## Column headings my @members = qw/ Algeria Indonesia Iran Iraq Kuwait Libya Nigeria Qatar Saudi_Arabia UAE Venezuela total_OPEC /; @members = map { tr/_/ /; $_ } @members; ## Load data my (%quotas, @dates, @notes, %notes); while () { ( my $period, $_ ) = split ':'; @{$quotas{$period}}{@members} = split ' '; push @dates, $period; } ## Load notes open (NOTES, 'notes.dat') or die "Couldn't open notes.dat: $!"; my @dates_copy = @dates; while () { $/ = "\n\n"; my $date = shift @dates_copy; push @notes, ($date, $_); %notes = @notes; } ## Introductory paragraph my $query = CGI->new(); print $query->header("text/html"), $query->start_html( -title => "QuotaBase: a database of OPEC oil production quotas", -bgcolor => "#cbcbcb" ), $query->h1("Welcome to QuotaBase!"), $query->table( $query->Tr( $query->td({-width => "600"}, $query->p(<current quotas are displayed. To view historical quota information, select the period you want from the drop-down list and click the 'Show quotas' button. A table of all the quotas for that period will be displayed. EOP ) ) ), $query->start_form(), "Choose a period: ", " ", $query->popup_menu( -name=>'period', -values=>[@dates], -default=>$dates[0]), "  ", $query->submit(-name=>'submit', -value=>'Show quotas'), "  ", $query->defaults('Reset current quotas'), $query->endform; ## Outer table print $query->start_table({ -border => 0, -width => 520 }), $query->start_Tr, $query->start_td; ## Data table my $period = $query->param('period') || $dates[0]; print $query->table({-border=>1}, $query->Tr( $query->td({-colspan=>2,-align=>"center"},"$period") ), map { $query->Tr( $query->td({-width=>130,-align=>"left" }, $_), $query->td({-width=>130,-align=>"right"}, $quotas{$period}{$_}) ) } sort keys %{$quotas{$period}} ); print $query->end_td, $query->start_td({-width=>260,-valign=>"top"}); ## Notes table print $query->table({-border=>1,-width=>260}, $query->Tr( $query->td({-align=>"center"},"Notes") ), $query->Tr( $query->td("$notes{$period}"), ), ); ## End outer table print $query->end_td, $query->end_Tr, $query->end_table; print $query->end_html; __DATA__ Jan 02 - Dec 02: 693 1125 3186 0 1741 1162 1787 562 7053 1894 2497 21700 Sep 01 - Dec 01: 741 1203 3406 0 1861 1242 1911 601 7541 2025 2670 23201 Apr 01 - Aug 01: 773 1255 3552 0 1941 1296 1993 627 7865 2113 2786 24201 Feb 01 - Mar 01: 805 1307 3698 0 2021 1350 2075 653 8189 2201 2902 25201