> -----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 a newline,
> so try something like:  chomp($s = <STDIN>);
> A+

True, but the newline doesn't affect the numeric comparison's he is using.

So, "3\n" == 3 is true.

> 
> 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 = <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