Re: The basics of SWITCH

2002-11-04 Thread Jeff 'japhy' Pinyan
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

Re: The basics of SWITCH

2002-11-04 Thread K Pfeiffer
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

Re: The basics of SWITCH

2002-11-04 Thread Robert Citek
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

Re: The basics of SWITCH

2002-11-04 Thread Jim Thomason
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,

RE: The basics of SWITCH

2002-11-04 Thread Bob Showalter
> -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

Re: The basics of SWITCH

2002-11-04 Thread Jean Padilla
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

RE: The basics of SWITCH

2002-11-04 Thread Bob Showalter
> -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

RE: The basics of SWITCH

2002-11-04 Thread David Samuelsson (PAC)
"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 cl

The basics of SWITCH

2002-11-04 Thread Gajo Csaba
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 == 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