#!/usr/bin/perl -w # Copyright (C) 2000-2003 Simon Huggins # simple just chooses a random tagline in the simplest possible way # or uses fortune(1) # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; my (@tags); # srand( time() ^ ($$ + ($$ << 15) )); # Since 5.004 not required. my $sig=""; open(SIG, "<$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n"; while() { $sig .= $_; } close(SIG); if (grep { /\@NOTAG\@/ } $sig) { $cfg{'notag'}=1; return 15; } htagdie < rand()) { my $cmd = $cfg{'fortune'}; $cmd .= " ".$cfg{'fortuneargs'} if defined $cfg{'fortuneargs'}; $tag = `$cmd`; htagdie "fortune died: $!" if $?; } else { foreach (@{$cfg{'tagfiles'}}) { open(HANDLE, "<$_") or htagdie "Could not open $_: $!\n"; push @tags, ; close(HANDLE); } if ($cfg{'tagline_comment_char'}) { @tags = grep { ! /^$cfg{'tagline_comment_char'}/ } @tags; } $tag = $tags[rand(@tags)]; } open(OUT, ">$cfg{'tmptagfile'}") or htagdie "$0: Could not open $cfg{'tmptagfile'}: $!\n"; reg_deletion("$cfg{'tmptagfile'}"); chomp $tag; print OUT $tag; close(OUT); return;