[Chicago-talk] We're famous, I guess...

Steven Lembark lembark at wrkhors.com
Tue Jan 6 23:48:29 CST 2004


<http://search.cpan.org/~petdance/Acme-PM-Chicago-0.01/>

Suggested modification:

 - You forgot to use map anywhere.
 - We normally need more than one name.
 - We usually have more people than books.

 therefore:

	# return a list of names in random order

	sub random_name
	{
		map { $_->[-1] }
		sort { $a->[0] <=> $b->[0] }
		map { [ rand, $_ ] }
		@_
	}	

=head1 EXAMPLE

	use Acme::PM::Chicago;

	my $num_books = shift or die "No books, no winners...\n";
	my @namz = <ARGV> or die "No names, no winners...\n";

	# leave the newlines on @namz for the output

	print "The winners are:\n", (random_name @namz)[0..$num_books-1];



--
Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 888 359 3508



More information about the Chicago-talk mailing list