#
# The Towers Of Hanoi
# Apache Web Server Module (Perl)
# Copyright (C) 2001 Amit Singh. All Rights Reserved.
# http://hanoi.kernelthread.com
#
#
# Configuration
# -------------
#
# Add the following lines to httpd.conf:
#
# PerlSetEnv PERL5LIB /path/to/some/directory
#
#
# SetHandler perl-script
# PerlHandler Hanoi
#
#
# This file (renamed to Hanoi.pm) must be located in the path defined above.
#
# Usage
# -----
#
# http://server.name/hanoi/solve/
#
# where is the number of disks to solve for
#
package Hanoi;
use strict;
use Apache::Constants qw(:common);
my $MAXDISKS = 10;
sub handler
{
my $r = shift;
$r->content_type('text/html');
$r->send_http_header;
$_ = $r->uri;
my $disks = 0;
if (/\/hanoi\/solve\/(\d+)/) {
$disks = int($1);
}
if (($disks < 0) || ($disks > $MAXDISKS)) {
$r->print(<The Towers Of Hanoi: *** error
The number of disks to solve for must be a positive integer
between 1 and $MAXDISKS, both inclusive.