Exercise: color selector

See other exercises

Given a list of colors (Blue, Yellow, Brown, White) create a script that will display a menu and ask the user to select one of the colors: For example an interaction would look like this:

$ perl color_selector.pl

Please select a number:
0) Blue
1) Yellow
2) Brown
3) White

2
The selected color is Brown

or like this:

$ perl color_selector.pl

Please select a number:
0) Blue
1) Yellow
2) Brown
3) White

7
Bad selection

Tools

Solutions