#!/usr/bin/perl -wT # -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*- # # repeat-01: Repetition Template Feature demo script # # Copyright (c) 2002 by Ian Hickson # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; use utf8; use CGI; my $query = new CGI; my @IDs = $query->param('id'); my $add = $query->param('add'); my $remove = $query->param('remove'); if ($add) { my $max = 0; foreach (@IDs) { if (m/^[0-9]+$/os and $_ > $max) { $max = $_; } } push(@IDs, $max + 1); } if ($remove) { foreach (@IDs) { if ($_ eq $remove) { $_ = undef; } } } if ($add or $remove) { local *FILE; print <) and $_ !~ m//os) { print $_; } print $_; foreach (@IDs) { next unless defined $_; use HTML::Entities; my $player = encode_entities($_, '<>&"'); my $name = encode_entities($query->param("player$_.name") || '', '<>&"'); my $bid = encode_entities($query->param("player$_.bid") || 0, '<>&"'); print < \$ end } while (defined($_ = ) and $_ !~ m/<\/tbody>/os) { # skip; } print $_; while (defined ($_ = )) { print $_; } close FILE; } else { print < Repetition Model Demo 01: Results

The bidders were:

    end my %IDs = (); foreach (@IDs) { next unless defined $_; $IDs{$_} = { name => $query->param("player$_.name") || '', bid => $query->param("player$_.bid") || 0, }; } foreach (sort { $IDs{$a}->{bid} <=> $IDs{$b}->{bid} } keys %IDs) { use HTML::Entities; my $player = encode_entities($_, '<>&"'); my $name = encode_entities($IDs{$_}->{name}, '<>&"'); my $bid = encode_entities($IDs{$_}->{bid}, '<>&"'); print < $name (\$$bid) end } print < end }