colorstring.cgi


#!/usr/bin/perl

use strict;
use CGI qw(param);

print "Content-type: text/html\n\n";

print "<html><body bgcolor=\"black\"><p>\n";

if (param('s')) {
    my @string = split(//,param('s'));
    foreach (@string) {
	s/ /\&nbsp\;/;
	print "<font style=\"" . random_style() . "\">" . $_ . "</font>\n";
    }
}

print "</p><p><form action=\"colorstring.cgi\" method=\"get\"><input type=\"text\" name=\"s\" value=\"CoLoRsTrInG\"><input type=\"submit\"></form></p>\n";

sub random_style {
    my $red = 20 + int(rand(255));
    my $green = 20 + int(rand(255));
    my $blue = 20 + int(rand(255));
    my $color = "rgb(" . $red . "," . $green . "," . $blue . ")";
    my $size = 12 + int(rand(38));
    return "color:" . $color . ";font-size:" . $size . "px;";
}