Initial add of defaria.com
[clearscm.git] / defaria.com / bin / oneliner
1 #!/usr/bin/perl -w
2 use strict;
3 use CGI qw/:standard :netscape/;
4
5 my $mode = param ("mode");
6 my $list = param ("list");
7
8 $mode = "html" if ! defined $mode;
9 $list = "no"   if ! defined $list;
10
11 srand;
12
13 $mode = "html" if $mode eq "";
14
15 print "Content-Type: text/html; charset=ISO-8859-1\n\n" if $mode eq "html";
16
17 my $home = $ENV{HOME};
18
19 if (! defined $home) {
20   # Fudge
21   $home = "/home/andrew";
22 }
23
24 my $sigs = $home . "/.signatures";
25
26 open SIGS, "$sigs" or die "Unable to open $sigs - $!\n";
27
28 my @sigs = <SIGS>;
29
30 if ($list eq "yes") {
31   print "<ol>\n" if $mode eq "html";
32
33   my $i=0;
34
35   foreach my $sig (@sigs) {
36     $i++;
37     if ($mode eq "html") {
38       print li ($sig) .  "\n";
39     } else {
40       print $i, ") ", $sig, "\n\n";
41     } # if
42   } # foreach
43
44   print "</ol>\n" if $mode eq "html";
45 } else {
46   print splice (@sigs, int (rand (@sigs)), 1) . "\n";
47 } # if
48
49 exit;