Menu: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) →{{header|Perl 6}}: Add Perl 6 example |
m →{{header|Perl 6}}: style tweaks |
||
Line 866: | Line 866: | ||
<lang perl6>sub menu ( $prompt, @items ) { |
<lang perl6>sub menu ( $prompt, @items ) { |
||
return '' unless @items.elems; |
return '' unless @items.elems; |
||
my $selection |
repeat until my $selection ~~ /^ \d+ $/ && @items[--$selection] { |
||
repeat until $selection ~~ /^ \d+ $/ && @items[--$selection].so |
|||
{ |
|||
my $i = 1; |
my $i = 1; |
||
say " {$i++}) $_" for @items; |
say " {$i++}) $_" for @items; |
||
Line 876: | Line 874: | ||
} |
} |
||
my @choices = |
my @choices = 'fee fie', 'huff and puff', 'mirror mirror', 'tick tock'; |
||
my $prompt = 'Enter the number corresponding to your selection: '; |
my $prompt = 'Enter the number corresponding to your selection: '; |
||