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

Re: [FWP] RFC



># Request for comments...  -Sneex-  :]
># Small mod to something I seen RS write.

Ok, so this is basically just a Fisher Yates shuffle, wrapped in code to
make it do X different shuffles?

>$sindex = chr(64 + (localtime)[3]);
>$eindex = ((ord($sindex) + 9) < 91) ?
>              chr(ord($sindex) + 9) :
>              chr(((ord($sindex) + 9) - 90) + 64);

This won't do exactly what you hope.  If $sindex is "Y", for instance,
then ("Y" .. "H") only returns ("Y" .. "Z").  You want something like:

  $start = chr(64 + (localtime)[3]);
  $end = 

>
>for (($ARGV[0]..$ARGV[1]) || 0) {
>  my @num = ($sindex..$eindex);
>  for (my $i = $#num; $i > 0; $i--) {
>    my $swapper = int rand(1+$i);
>    if ($swapper < $i) {
>      @num[$i,$swapper] = @num[$swapper,$i];
>    }
>  }
>  print "@num\n";
>}
>
>__END__
>
>???
>-Sneex-  :]
>- FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 -
>
>
>==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
>==== Send email to <fwp-request@technofile.org> with message _body_
>====   unsubscribe
>

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe