🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #15574

Random .signature changer

#15574
From: J.D. Falk
Date: Sat, 25 Feb 1995 07:38
68 lines
2864 bytes
[continuing a thread I started in news.software.readers]

	Well, based on the script I was already using and the ones posted
here, I came up with something which is /close/ to what I'd been hunting
for -- it now randomly chooses each time the .signature file is read. 
	Now I just need to steal s'more code (unless somebody can think 
of something simpler) so that, for example, I use one specific file every 
time I'm reading alt.internet.media-coverage, but keeps scrambling in all 
the other groups.
	Also, this routine doesn't quite work right with PINE -- I have 
to manually load the .signature file, even though my .pinerc is set right 
and /used/ to work.
	Obviously, it requires a mkfifo command to start working right.

---------- [~/perl/scramble2]
#!/usr/bin/perl
#
# J.D.'s Sunny Side Signature Scrambler
# Based on a bunch of perl routines written by better programmers than me
#

$HOME = "/home/jdfalk";
$name = shift || ($name = "");
$FIFO = "$HOME/.signature";
$MKNOD = "/etc/mknod";
$QUOTES = "$HOME/TAG/.quotes";

unless (-p $FIFO) {
	if (!-e _) {
		system("$MKNOD $FIFO p");
		warn "Created $FIFO as a named pipe\n";
	} else {
		die "$0: won't overwrite file $FIFO \n";
	}
}

MAIN: while (1) {
	open (FIFO, "> $FIFO") || die "Can't write FIFO: $!";

	open(QUOTES, "$QUOTES") || die "Cannot open ~/.quotes for input.\n"; while(<QUOTES>) {
		if(/^\s*#\s*$/) {
			if($quote) {
				if( ($name EQ "") || ($quote =~ /$name/i) ) {
					push(@quotes, $quote);
				}
			}
			undef $quote;
			next;
		}
		$quote .= $_;
	}
	close(QUOTES);

	srand(time()^$$);
	$index = int(rand(@quotes));

	print FIFO $quotes[$index];	
	close FIFO;

	sleep 2;
}
---------- [ END ]
-- 
 -------------========== J.D. Falk <jdfalk@cais.com> =========-------------
  |   "I came alone as me, just an idea in a long chain of discovery."   |
  |                                      -Roy Harper                     |
 --------========== http://www.cais.com/jdfalk/home.html ==========--------
Technical Details
Message-ID: <3immpm$kie@news.cais.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.lang.perl.mbox.zip!nntp.gmd.de!stern.fokus.gmd.de!ceres.fokus.gmd.de!zib-berlin.de!news.mathworks.com!news.alpha.net!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!news.sprintlink.net!news.cais.com!cais.cais.com!jdfalk
References: <3iearp$227@news.cais.com>

Show Full Headers
Complete Article Headers
Message-ID: <3immpm$kie@news.cais.com>
Subject: Random .signature changer
Date: Sat, 25 Feb 1995 07:38:30 +0000
From: jdfalk@cais.cais.com (J.D. Falk)
References: <3iearp$227@news.cais.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.lang.perl.mbox.zip!nntp.gmd.de!stern.fokus.gmd.de!ceres.fokus.gmd.de!zib-berlin.de!news.mathworks.com!news.alpha.net!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!news.sprintlink.net!news.cais.com!cais.cais.com!jdfalk
Newsgroups: news.software.readers,comp.lang.perl
Organization: Schroedinger's Cats
Lines: 67
Reply-To: jdfalk@cais.com
NNTP-Posting-Host: cais.com
Keywords: perl signature