if i am going to do something like this i would have done:

use strict;
my ($answer);
#create menu
print "\n\n\t\t\tinstall menu\n\n";
print "\t\t\tChoose one of the following options..\n";
print "\t\t\t1. Install/reinstall xxx.\n";
print "\t\t\t2. Install/reinstall xxx.\n";
print "\t\t\t3. Uninstal xxx.\n";
print "\t\t\tpress 1 to 3 to select. Finish with enter\n";
while (defined($answer = <STDIN>)) {
chomp $answer;
if ($answer eq "1")
    {
        do blah
    }
if ($answer eq "2")
    {
 etc..
else
{
    print "ERROR: Must submit choice between 1 to 3.\n";
    die;
}

//Dave

-----Original Message-----
From: Gajo Csaba [mailto:[EMAIL PROTECTED]]
Sent: den 4 november 2002 15:18
To: perl-beginners
Subject: The basics of SWITCH


Hi, I have a problem with SWITCH. I wrote this, I think 
it's clear to anzone what it should do:

print "Type in a number 1-5: ";
$s = <STDIN>;
SWITCH;
{
 if ($s == 1) { print "one\n"; last SWITCH; }
 if ($s == 2) { print "two\n"; last SWITCH; }
 if ($s == 3) { print "three\n"; last SWITCH; }
 if ($s == 4) { print "four\n"; last SWITCH; }
 if ($s == 5) { print "five\n"; last SWITCH; }
}

And I get an error message saying "Label not found 
for "last SWITCH" at line 11. <STDIN> chunk 1." (with line 
11 being the first line of the chunk)

So what's wrong?

Also, how can I do something like in bash, where I have 
options 1), 2)... and also *). That is, how can I do that 
*) thing? :)

Thanks, Csaba



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to