Using switch - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: Using switch

> On Wed, 14 Jul 2004, Gabkin wrote:
>> I want to use a switch .. case  statement in my program.
>> I looked it up with 'perldoc switch' and found the help.
>> I tested some code from the perldoc switch help and it failed.
>> This is what I tried...
>> use switch;
>       ^
> On my system, the module is, not  Case matters.
>> print("Enter a digit\n");
>> $var = <STDIN>; chop $var;

In addition, this seems a little more elegant:

 chomp ($var = <STDIN>);

> not that it matters in this case, but you almost always want chomp()
> rather than chop().   Look them up to see why.
> Paul Lalli

Site Timeline