Example 4-7. examples/arrays/color_menu_option.p6
#!/usr/bin/perl6
my $color = @*ARGS[0];
if (not $color) {
my @colors = ("Blue", "Yellow", "Brown", "White");
for 1..@colors.elems -> $i {
say "$i) @colors[$i-1]";
}
print "Please select a number: ";
my $input = =$*IN;
$color = @colors[$input-1];
}
say "You selected $color";
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| Array assignment | Up | Process CSV file |