#! /usr/bin/perl

use warnings;
use strict;

use IO::File;

my $sigfile      = new IO::File "> /home/don/.signature";
my $templatefile = new IO::File "/home/don/signature_stuff/sigtemplate.txt";
my $quotesfile   = new IO::File "/home/don/signature_stuff/quote.txt";

my $template = '';

while (<$templatefile>) {
     $template.=$_;
}

undef $templatefile;

my $quotes = '';

while (<$quotesfile>) {
     $quotes.=$_;
}

undef $quotesfile;

my @quotes = split /\n*\%\n*/s, $quotes;
undef $quotes;

my $quote = $quotes[rand($#quotes+1)];

$template =~ s/\[\%\s*quote\s*\%\]/$quote/;

print {$sigfile} $template;

undef $sigfile;
