Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: STDIN method?

by janx (Monk)
on Oct 17, 2002 at 20:42 UTC ( #206139=note: print w/replies, xml ) Need Help??


in reply to STDIN method?

No, sorry. There is no built-in case/switch statement (yet - in Perl 6 there will be, it's called given).
If you don't mind source filters though, there is the excellent module Switch.pm by Damian Conway.

Otherwise you will have to use if/elsif statements.

Be aware:

> $choice=<STDIN>; > if ($choice="1") { > $choice="Turkey"; > } > else choice="2"...etx
= assigns, it does not compare!
Use eq for string comparison (or == for a numeric one).

janx

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://206139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2023-03-28 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (68 votes). Check out past polls.

    Notices?