#!/usr/bin/perl # Note. HEAD requests are not really supported by the CGI system here. # Or so it seems, anyway. # Initialise System use CGI; my $query = new CGI; ############################################################ # Select mode by looking for "NestingLevel" parameter my $NestingLevel = $query->param('NestingLevel'); if (($NestingLevel =~ m/^-?\d+$/) and ($NestingLevel >= 0)) { ##### Parameter Present: Create Stylesheet ##### # Initialize class number my $Class = $query->param('Class'); $Class =~ s/[^-a-zA-Z0-9]/-/go; if ($Class eq "") { $Class = "-none-"; } ############################################################ # Print HTTP Header print "Content-Type: text/css\r\n"; print "Cache-Control: no-cache\r\n\r\n"; ############################################################ # Print Copyright Information print "\r /* This is a very deeply nesting stylesheet.\r ** It is created by nested-stylesheets.pl, which was\r ** written by Ian Hickson with help from Liam Quinn.\r ** \r ** (c) copyright 1999 by Ian Hickson\r ** http://software.hixie.ch/utilities/cgi/test-tools/\r ** \r ** Nesting Level: $NestingLevel\r ** Class: \"$Class\"\r */\r "; ############################################################ # Print next level or actual stylesheet if ($NestingLevel-- > 0) { print "\r \@import url(http://software.hixie.ch/utilities/cgi/test-tools/nested-stylesheets?NestingLevel=$NestingLevel&Class=$Class);\r "; } else { print "\r .good-$Class { background: white none; color: green; font-weight: bold; }\r .bad-$Class { background: red none; color: yellow; }\r "; } ############################################################ # Print footer print "\r /* End */\r "; ############################################################ } else { ##### Parameter Missing: Create Documentation ##### # Print HTTP Header print "Content-Type: text/plain\r\n"; ############################################################ # Print Help Information print "\r nested-stylesheets.pl 1.0\r =========================\r \r This is a perl CGI script that creates a set of self-referencing\r nested stylesheets.\r \r To call this script, use the following:\r http://software.hixie.ch/utilities/cgi/test-tools/nested-stylesheets?NestingLevel=X&Class=Y\r ...where:\r X is an integer giving the required nesting level, and\r Y is a class identifier.\r \r This will link to stylesheet X. Stylesheet X will link to sheet\r X-1, which will link to X-2, and so on until stylesheet 1, which\r links to the final stylesheet, stylesheet 0. Hence there will be\r X+1 stylesheets in total -- and X \@imports.\r \r The final stylesheet will contain classes for \"good-YYY\" and \"bad-YYY\", green and red respectively. \r Incidentally, this script was written by Ian Hickson with help\r from Liam Quinn. It is (c) copyright 1999 by Ian Hickson. It is\r also distributed under the GNU GPL. Use freely and all that.\r \r You can email me at test-tools\@hixie.ch\r \r "; ############################################################ }