in reply to Re^2: I have a list expanding when I don't want it to
in thread I have a list expanding when I don't want it to
pojsub random { my ($user_input, $list) = @_; if ($user_input =~ /(?:help|options)/) { my $keys = join ", ",keys %$list; return "Your options are: $keys, or all."; } elsif ($user_input eq 'dump') { use Data::Dumper; return Dumper($list); } else { my @values=(); if ($user_input eq 'all'){ @values = map { @$_ } values %$list; } else { @values = values @$list{$user_input}; } return (shuffle @values)[0]; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: I have a list expanding when I don't want it to
by Lady_Aleena (Priest) on Nov 23, 2014 at 08:28 UTC | |
|
Re^4: I have a list expanding when I don't want it to
by Lady_Aleena (Priest) on Nov 20, 2014 at 09:48 UTC |