#!/usr/bin/perl -w
# produce as output to stdout, an email signature

open SIGS, "<.emailsigs.txt";
  @sigs = <SIGS>;
close (SIGS);

chomp @sigs;

# find out how many signatures there are
$n = 0;
$dlim = $sigs[0];
foreach $x (@sigs) {
  if ($dlim eq $x) {
    $n++;
  };
};

print "Regards,\n\n\nYour name here\n\n";
print "http://www.your.homepage.here.com/\n";

# Pick one at random
$r = int( rand( $n ) ) + 1;

# copy it
$n = 0;
foreach $x (@sigs) {
  if ($dlim eq $x) {
    $n++;
  };
  if ($n == $r) {
    # now in that part of the loop
    unless ($dlim eq $x) {
      push @opsig, $x;
    };
  };
};

# find the longest line
$max = 0;
foreach $x (@opsig) {
  if ($max < length($x)) {$max = length($x)};
};
$equ = "=" x $max;
print "$equ\n\n";
foreach $x (@opsig) {
  print "$x\n";
};
print "\n$equ\n";

print "any more bits here such as a disclaimer\n";
