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