gnump3d-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnump3d-users] Handling the random selection options


From: Steve Kemp
Subject: Re: [Gnump3d-users] Handling the random selection options
Date: Mon, 21 Feb 2005 17:59:36 +0000
User-agent: Mutt/1.3.28i

On Mon, Feb 21, 2005 at 11:03:30AM -0500, Stuffed Crust wrote:

> Honestly the simple solution would be along the lines of:
> 
> random_exclude_regexp = (private|trashyPop|demos)
> 
> Or we could go fancier and have, say, a tab delimited list of regexps to 
> apply.

  I can't help thinking that this is going to get messy, thinking
 of doing this for my personal archive I'd have:

random_exclude = (Spoken/The Hobbit|TV Stuff/Samples/Wav's| .. )

  I find it easier to just reload when this happens although I guess
 that I'm alone here!

  How about this?

--- random.pm   2005-02-06 14:07:27.000000000 +0000
+++ random.pm.orig      2005-02-21 17:51:34.000000000 +0000
@@ -380,10 +380,27 @@
     close( FILY );
 
     # Pick a random line from the database.
-    my $random = $lines[ rand @lines ];
-    if ( $random =~ /([^\t]+)\t(.*)/ )
+    my $random = "";
+
+    #
+    #  Continue choosing a random directory until we find one
+    # that hasn't been explicitly disallowed.
+    #
+    my $excluded = getConfig( "random_exclude_dirs", "" );
+
+    while ( ! length( $random ) )
     {
-       $random = $1;
+        $random = $lines[ rand @lines ];
+       if ( $random =~ /([^\t]+)\t(.*)/ )
+       {
+           $random = $1;
+       }
+
+       #
+       #  If it matches the ignored list then loop to choose
+       # again.
+       #
+       $random = "" if ( $excluded =~ /$random/ ) ;
     }
 
     #

Steve
---




reply via email to

[Prev in Thread] Current Thread [Next in Thread]