| 1 | #!/usr/bin/perl |
| 2 | # jibberish -- run all filters in random order |
| 3 | |
| 4 | $ENV{PATH}.=":/usr/games"; |
| 5 | |
| 6 | @all= qw( |
| 7 | eleet |
| 8 | b1ff |
| 9 | chef |
| 10 | jethro |
| 11 | upside-down |
| 12 | kraut |
| 13 | cockney |
| 14 | jive |
| 15 | nyc |
| 16 | ); |
| 17 | |
| 18 | @nonfree= qw( |
| 19 | kyoote |
| 20 | newspeak |
| 21 | ); |
| 22 | |
| 23 | # Test to see if non-free filters are here, if so, add them to @all. |
| 24 | foreach (@nonfree) { |
| 25 | if (-x "/usr/games/$_") { |
| 26 | push @all, $_; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | # shuffle order |
| 31 | srand; |
| 32 | for (0..$#all) { |
| 33 | my $n= @all*rand; |
| 34 | my $was= $all[$_]; |
| 35 | $all[$_]= $all[$n]; |
| 36 | $all[$n]= $was; |
| 37 | } |
| 38 | |
| 39 | # start the pipe... |
| 40 | my $pipe= join '|', @all; |
| 41 | open FILTER, "$pipe|" |
| 42 | or die ""Never mind...\n";; |
| 43 | |
| 44 | # display the results |
| 45 | while (<FILTER>) { |
| 46 | print $_ |
| 47 | } |
| 48 | |
| 49 | # This could be optimized: take the last program off the pipeline, |
| 50 | # open the pipeline as standard input, then exec that last program. |
| 51 | # |
| 52 | # But you have to ask yourself: how important is it to optimize |
| 53 | # the generation of jibberish? |