<quote name="James Lance" date="Fri, 13 Jun 2008 at 10:21 -0600">
> So this fails the easy to remember requirement, but I coded this up at a
> previous PLUG meeting so I though I would included it.
>
> #!/usr/bin/perl
> use strict;
>
> my $limit = $ARGV[0];
> unless ( $limit ) { die "Please specify a limit ex: ./grab_bag_generator.pl
> 25\n";}
>
> my %seen = ();
>
> my $run = 1;
>
> while ($run) {
> my $num = int(rand($limit)) + 1;
> unless ( $seen{$num} ) {
> print "$num\n";
> $seen{$num}++;
> print "Run again? (yn) ";
> $_ = <STDIN>;
> chomp;
>
> if ( $_ =~ m/[nN]/ ) {
> $run = 0;
> }
> }
>
> if ( scalar(keys %seen) >= ($limit) ) { $run = 0 }
> }
>
> -JamesHey, excluding already generated numbers is *not* random, and it flies in the face of the multiple prizes for Fugals tradition! Von Fugal
signature.asc
Description: Digital signature
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
