Search for '{{search_term}}'

Exercise: color selector

CMOS is the Code-Maven Open Source podcast that also includes video interviews. Subscribe to this feed RSS feed with your Podcast listener app or via iTunes iTunes.

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

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus