#!/usr/bin/perl

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

@wds = (
  "benefit",
  "budget",
  "capital ",
  "catalyst",
  "direct",
  "diverse",
  "dot-com",
  "e-commerce",
  "efficient",
  "engenuity",
  "enhance",
  "fortune-500",
  "foster",
  "global",
  "goal",
  "hand-holding",
  "indirect",
  "innovate",
  "integrate",
  "intellectual-property",
  "information-centric",
  "infrastructure",
  "international",
  "leadership",
  "leverage",
  "maintain",
  "market-capitalization",
  "market-driven",
  "mission-critical",
  "network",
  "paradigm",
  "parallel",
  "proactive",
  "professional",
  "revenue",
  "revolutionize",
  "scalable",
  "seamless",
  "sense-of-urgency",
  "solution",
  "stock-split",
  "storage",
  "synergy",
  "technology",
  "terrabyte",
  "time-to-market",
  "unique",
  "value-added",
  "virtual",
  "world-class"
);

for $c (0 .. 23) {
    $i = int(rand($#wds + 1));
    chomp($bd[$c] = splice(@wds, $i, 1));
}

splice(@bd, 12, 0, "FREE-SPACE");

# Compute board size parameters
for $c (0 .. 24) {
    @tmp = (split(/-/, $bd[$c]));
    $lines[int($c / 5)] = scalar(@tmp)
        if scalar(@tmp) > $lines[int($c / 5)];
    for $tmp (@tmp) {
        $length[$c % 5] = length($tmp)
            if length($tmp) > $length[$c % 5];
    }
}

for $_ (0..4) {
    $hor += $length[$_];
    $ver += $lines[$_];
}

$div = "----------------";
for $_ (1..$hor) {
    $div .= "-";
}
$div .= "\n";

print "<PRE>\n";
for $_ (0..4) {
    print $div;
    for $r (0..($lines[$_] - 1)) {
        for $c (0..4) {
            printf("| %-$length[$c]s ", (split(/-/, $bd[$c + ($_ * 5)]))[$r]);
        }
        print "|\n";
    }
}
print $div;
print "</PRE>\n";

