Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Perl / Getting Started / February 2005



Tip: Looking for answers? Try searching our database.

Case-operator

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vladimir D Belousov - 28 Feb 2005 12:01 GMT
Hallo!

Is in the perl operator like C/C++ 'case' ?

Signature

Vladimir D Belousov
HiTech solutions for business
http://businessreklama.ru

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Ricardo SIGNES - 28 Feb 2005 12:18 GMT
* Vladimir D Belousov <maillist@klarnet.ru> [2005-02-28T07:01:02]
> Is in the perl operator like C/C++ 'case' ?

I believe you are asking: Is there Perl equivalent to C's switch/case
construct?

Not exactly.

To see the official Perl documentation on this, run: perldoc -q case

This will search the FAQs for the keyword "case" and in the second
question you'll get some information, and a pointer to another bit of
Perl documentation, the "perlsyn" page.

A common idiom is something like this:

 SWITCH: for ($value) {
   /regex/    and do { something($x); last SWITCH };
   /regex/    and do { something($y); last SWITCH };
   (! $value) and do { something(0);  last SWITCH };

   something($default);
 }

The documentation mentions Switch, the module.  While Switch is neat, I
wouldn't suggest using it in production.

Signature

rjbs

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.