adiolord has asked for the wisdom of the Perl Monks concerning the following question:

Basically I have to prompt the user for a case insensitive selection of either (a, A, b, B) string value, if they choose a/A, display all 255 ASCII characters in an array in ascending order, b/B, descending order. If neither a/A/b/B are chosen report an invalid selection and loop until successful. I am brand new to Perl and would love some help getting this script off the ground. Thankyou!

Replies are listed 'Best First'.
Re: First Script
by FunkyMonk (Bishop) on Feb 09, 2009 at 23:21 UTC
    Welcome to the Monastery adilord.

    Your question sounds like homework. Why not post the code you've tried so far (surrounded by <code>...</code> tags, and the Monks will be sure to help you.

Re: First Script
by toolic (Bishop) on Feb 10, 2009 at 01:57 UTC
    Since you have shown no code, I will assume you do not know how to create code for any of the tasks you mentioned. So, I will point you to some documentation here at the Monastery which should show some examples of the types of things you want to do. The Tutorials section is a great resource.

    For example, to prompt the user, take a look at Basic Input and Output.

    Search for "case-insensitive" in the perlrequick section of the official Perl documentation.

Re: First Script
by CountZero (Bishop) on Feb 10, 2009 at 06:20 UTC
    Assuming you are using ActiveState Perl, you can use the prompt function from the ActiveState::Prompt module. It does all you want and more:
    use strict; use warnings; use ActiveState::Prompt qw/prompt/; my $answer = prompt('Please enter a, A, b, B', must_match => [qw/a A b B/], no_match_msg => 'a, A, b or B only please!', ); print $answer;

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: First Script
by irah (Pilgrim) on Feb 10, 2009 at 04:07 UTC
    You can use simple if, elsif and else. To get ASCII character see, ord function. To print in reverse order, see chr function.
Re: First Script
by bichonfrise74 (Vicar) on Feb 10, 2009 at 00:53 UTC
    This sounds pretty straight-forward and easy.