#!/usr/bin/perl
use diagnostics;
use warnings;
use strict;
use CGI;
my %all_quotas;
my @members = ('Algeria', 'Indonesia', 'Iran', 'Iraq', 'Kuwait', 'Libya', 'Nigeria', Qatar', 'Saudi Arabia', 'UAE', 'Venezuela', 'total OPEC' );
# Sorry about the ghastly ASCIIbetical hack. Suggestions welcome!
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->start_table(),
$query->Tr(),
$query->td({-width => "600"}),
$query->p("QuotaBase is an interactive database of OPEC oil production quotas. By default, the 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."),
$query->end_td(),
$query->end_Tr(),
$query->end_table(),
$query->start_form(),
"Choose a period: ",
" ",
$query->popup_menu( -name=>'period',
-values=>['Jan 02 - Dec 02', 'Sep 01 - Dec 01', 'Apr 01 - Aug 01', 'Feb 01 - Mar 01', '31 Oct 00 - Jan 01', '1 Oct 00 - 30 Oct 00'],
-default=>'Jan 02 - Dec 02'),
" ",
$query->submit(-name=>'period', -value=>'Show quotas'),
" ",
$query->defaults('Reset current quotas'),
$query->endform;
$query->end_p(),
build_database();
my @$period = $query->param('period');
process_query(@$period);
print $query->end_html;
##### subs #####
sub build_database { # thanks to Zaxo
while () {
( my $period, $_ ) = split ':';
@{$all_quotas{$period}}{@members} = split ' ';
}
}
sub process_query {
($period) = @_;
if ($period) {
print_table();
} else {
$period = 'Jan 02 - Dec 02';
print_table();
}
}
sub print_table {
print "