#!/usr/bin/perl
#randsig.pl, by Don Blaheta.  Released into public domain, blah, blah, blah.
# Generates a signature randomly from a single file of witty quotes which
# the user maintains; the quotes can be multi-line, and are separated by
# blank lines.


#Insert your constant tagline here.
$sigline = 
  '-=-=-=-=-=-Your Name Here-=-=-=-=-=-your.name@your.address.com-=-=-=-=-=-';

#Put your sigfile in ~/.randsig, or else change the following appropriately
$home =  $ENV{"HOME"};
open (FI, "$home/.randsig") or die "Can't open sigfile";

$sig[0] = 0;
while (<FI>) { $sig[$#sig + 1] = tell if /^$/; }

srand;
seek(FI, $sig[int rand ($#sig + .9999)], SEEK_SET) or die "Can't seek";
while (<FI>) {
	last if /^$/;
	$msg .= $_;
}

print "$sigline\n$msg";


#Uncomment the next three lines if you also want your sig to be
#outputted to ~/.sig (I do this because of some vi macros I have).

#open (SIG,">$home/.sig");
#print SIG "-- \n$sigline\n$msg";
#close SIG;
