On Tue, 7 Dec 2004, Charles K. Clarkson wrote:

> Chris Devers <[EMAIL PROTECTED]> wrote:
> 
> : I have a similar script on my site, but I use it to select
> : a random stylesheet instead of a random image. Same idea
> : though.
> : 
> :   #!/usr/bin/perl -w
> : 
> :   use strict;
> :   use CGI;
> : 
> :   my $q = new CGI;
> :   my @sheets = <*.css>;
> : 
> :   use List::Util 'shuffle';
> :   @sheets    = shuffle( @sheets );
> 
>     Why shuffle it *and* pick a random one?

Good point. I guess cutting the deck doesn't make as much sense in 
software :-)

I think at one time I was trying to do something more ambitious with 
this script, then pared it back and never refactored.

That or I was just playing around with List::Util; it's been a while 
since I wrote this and my memory is hazy now.
  
> use CGI;
> 
> my @sheets = <*.pl>;
> 
> print CGI::redirect( $sheets[ rand @sheets ] );
 
This way is clearly better than my suggestion.

 

-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to