On Nov 4, K Pfeiffer said:
>Gajo Csaba writes:
>> Hi, I have a problem with SWITCH. I wrote this, I think
>> it's clear to anzone what it should do:
>
>Just out of curiousity I typed in 'perldoc SWITCH' and 'perldoc -f SWITCH'
>and found nothing. What is it? (the short answer is fine)
It is nothi
Gajo Csaba writes:
> Hi, I have a problem with SWITCH. I wrote this, I think
> it's clear to anzone what it should do:
Just out of curiousity I typed in 'perldoc SWITCH' and 'perldoc -f SWITCH'
and found nothing. What is it? (the short answer is fine)
Thanks,
Kevin
--
Kevin Pfeiffer
Internatio
Hello Gajo,
A different approach to your problem is to use a data structure, e.g. an
array or hash. Your script rewritten using an array,
#!/usr/bin/perl -w
my @option = ("one","two","three","four","five","six","maybe seven?");
print "Type in a number 1-", $#option+1, ": ";
$s = ;
chomp $s ;
i
Try this:
SWITCH:
{
$s == 1 && do {print "one\n"; last SWITCH;};
$s == 2 && do {print "two\n"; last SWITCH;};
$s == 3 && do {print "three\n"; last SWITCH;};
$s == 4 && do {print "four\n"; last SWITCH;};
$s == 5 && do {print "five\n"; last SWITCH;};
print " No match found.\n";
}
You need a colon,
> -Original Message-
> From: Jean Padilla [mailto:jean.padilla@;ac-montpellier.fr]
> Sent: Monday, November 04, 2002 9:41 AM
> To: Gajo Csaba
> Cc: perl-beginners
> Subject: Re: The basics of SWITCH
>
>
> Hi,
> when you get $s from STDIN, it comes along with
Hi,
when you get $s from STDIN, it comes along with a newline,
so try something like: chomp($s = );
A+
Gajo Csaba a écrit :
>
> 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 = ;
> SWITCH;
> {
> if ($s
> -Original Message-
> From: Gajo Csaba [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 04, 2002 9:18 AM
> 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
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. Uninsta