Description: A really short little ditty to take a file delimited by '%' characters (on lines by themselves) then randomly select an entry, then print it to the .signature file.

Literally taken straight from my ~/scripts directory, all still hardcoded. Pick it to pieces, but remember it's just a hack :)

First few lines of my .signature.rot file. Note the first line is blank, and there needn't be a trailing newline at the end:

Leo: (July 23 - Aug. 22) When driving through the desert, you should never stop and eat mysterious piles of birdseed, even if "FREE BIRDSEED" signs are stuck in them. % "Reality is that which, when you stop believing in it, doesn't go away". -- Philip K. Dick % So, Lone Starr, now you see that evil will always triumph, because good is dumb. -- Dark Helmet % Thank you for pressing the self-destruct button. This ship will self-destruct in three minutes. % Do you make up these questions, Mr. Holden, or do they write them down for you? % Yes, questions. Morphology, longevity, incept dates. % "Begun, this clone war has." Donate to the House With No Sentence Structure. Dedicated to assisting grammatically disadvantaged Jedi for over 900 years.

use IO::File;

$/ = "%";

open(FILE, "/home/hagus/.signature.rot");
while (<FILE>)
    $tmp = $_;
    $tmp =~ s/%//g;
    push @a, $tmp;

my $fh = new IO::File("/dev/urandom", "r");

my $foo = $fh->read($value, 100);


my $num = unpack("S*", $value);

my $index = $num % (@a + 0);

open(FILE, ">/home/hagus/.signature");
print FILE $a[$index] . "\n";