]> git.donarmstrong.com Git - lib.git/blob - signature_stuff/pick_a_quote.pl
move the heroin quote to offensive quotes
[lib.git] / signature_stuff / pick_a_quote.pl
1 #! /usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use IO::File;
7
8 use User;
9
10 my ($temp_file,$quote_file) = @ARGV;
11 $temp_file  ||= User->Home."/lib/signature_stuff/sigtemplate.txt";
12 $quote_file ||= User->Home."/lib/signature_stuff/quote.txt";
13
14 my $sigfile      = new IO::File User->Home."/.signature", 'w' or die "Unable to open ~/.signature for writing; $!";
15 my $templatefile = new IO::File $temp_file, 'r' or die "Unable to open $temp_file $!";
16 my $quotesfile   = new IO::File $quote_file,'r' or die "Unable to open $quote_file $!";
17
18 my $template = '';
19
20 while (<$templatefile>) {
21      $template.=$_;
22 }
23
24 undef $templatefile;
25
26 my $quotes = '';
27
28 while (<$quotesfile>) {
29      $quotes.=$_;
30 }
31
32 undef $quotesfile;
33
34 my @quotes = split /\n*\%\n*/s, $quotes;
35 undef $quotes;
36
37 my $quote = $quotes[rand($#quotes+1)];
38
39 $template =~ s/\[\%\s*quote\s*\%\]/$quote/;
40
41 print {$sigfile} $template;
42
43 undef $sigfile;