in reply to Question regarding variable scope
sub find_paring() { my $white_player = shift; my $black_player = "none"; # Get a list of players still in the running my @possible_opponents = keys %{$matches_remaining{$white_player}}; # Shuffle the list to add some randomness, then find the first # avaliable opponent. &shuffle(\@possible_opponents); foreach (@possible_opponents) { # Once we have a valid match, we remove the entries from the # match hash, and return the pair. if (exists $matches_remaining{$_}{$white_player}){ $black_player = $_; delete $matches_remaining{$white_player}{$_}; delete $matches_remaining{$_}{$white_player}; last; } } # Return the info we have return ($white_player, $black_player); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Question regarding variable scope
by Rhandom (Curate) on Oct 17, 2003 at 15:25 UTC | |
by Roger (Parson) on Oct 18, 2003 at 08:13 UTC |