[K12OSN] Whoops! Script usage-DansGuardian blacklists...how to randomize?

David Trask dtrask at vcsvikings.org
Wed Aug 3 13:37:48 UTC 2005


Whoops!  Usage for the script I posted below is  (i named it random.pl as
that's what they called it originally)

./random.pl sortedfile unsortedfile

David Trask on Wed Aug  3 2005 at 09:34 +0000 wrote:
>"Support list for opensource software in schools." <k12osn at redhat.com> on
>Wed Aug  3 2005 at 01:03 +0000 wrote:
>On Tue, 2 Aug 2005, David Trask wrote:
>
>> So....my question...any idea on how to randomize the blacklists from
>Eric?
>> I'd be willing to do it and then host it or send it back to Eric for
>> hosting.  I just have no clue at this point how to do it....anyone?
>
>It would be trivial for me to "unsort" the list and export it like I do
>the sorted list.
>
>But not tonight, my brain is too fried from a long day ;-)
>
>-Eric
>
>Eric....you da' man!
>
>Here's a script to help you out!  :-)   Wish I could say I wrote it, but
>I didn't....Got it from Stephen Noble in Dungog, Australia....and I think
>he originally got it from the DG site.  Nonetheless, if you're able to
>randomize your lists...that'd be awesome as DG is so gawdawful slow at
>loading sorted lists it's not worth it, and many of us LOVE using your
>awesome list.  I've been using it for years now.  :-)
>
>Script below:
>
>#!/usr/bin/perl -w
>
># randomize source file
># lines are output in random order
>
># reads from from stdin or arg0, writes to stdout or arg1
>open (STDIN, $ARGV[0]) if (($ARGV[0] ne "") && ($ARGV[0] ne "-"));
>open (STDOUT, ">$ARGV[1]") if ($ARGV[1] ne "");
>
>@list = <STDIN>;
>
>while (@list) {
>  $rand = rand (@list);
>  print $list[$rand];              # for indexing rand is truncated
>  splice @list, $rand, 1;          # delete array element
>}


David N. Trask
Technology Teacher/Coordinator
Vassalboro Community School
dtrask at vcsvikings.org
(207)923-3100




More information about the K12OSN mailing list