#!/usr/bin/perl
# jibberish -- run all filters in random order

$ENV{PATH}.=":/usr/games";

@all= qw(
eleet
b1ff
chef
jethro
upside-down
kraut
);

@nonfree= qw(
cockney
jive
kyoote
newspeak
nyc
);

# Test to see if non-free filters are here, if so, add them to @all.
foreach (@nonfree) {
	if (-x "/usr/games/$_") {
		push @all, $_;
	}
}

# shuffle order
srand;
for (0..$#all) {
	my $n= @all*rand;
	my $was= $all[$_];
	$all[$_]= $all[$n];
	$all[$n]= $was;
}

# start the pipe...
my $pipe= join '|', @all;
open FILTER, "$pipe|"
	or die "&quot;Never mind...\n";;

# display the results
while (<FILTER>) {
	print $_
}

# This could be optimized: take the last program off the pipeline,
# open the pipeline as standard input, then exec that last program.
#
# But you have to ask yourself: how important is it to optimize
# the generation of jibberish?
