cmikel has asked for the wisdom of the Perl Monks concerning the following question:
this below code does not work - while i can execute my program - nothing is getting returnedsub get_random_room { my $self = shift; my $random_room = ''; if ( defined $self->{exits} ) { $random_room = $self->{exits}{ ( keys %{$self->{exits}} ) +[ rand keys %{$self->{exits}} ] }; #no random exiting if ($random_room eq 'exit') { $random_room = 'hallway'; } return $random_room; } }
thanks.sub get_random_room { my $self = shift; my $random_room = ''; if ( defined $self->{exits} ) { $random_room = $self->{exits}{ ( keys %{$self->{exits}} ) +[ rand keys %{$self->{exits}} ] } unless ('exit'); return $random_room; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Random Values from Hash with UNLESS statement
by LanX (Saint) on Apr 23, 2013 at 01:32 UTC | |
|
Re: Random Values from Hash with UNLESS statement
by hdb (Monsignor) on Apr 23, 2013 at 06:13 UTC | |
by cmikel (Novice) on Apr 23, 2013 at 13:44 UTC |