* Vladimir D Belousov <[EMAIL PROTECTED]> [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.

-- 
rjbs

Attachment: pgpVyCErbsaer.pgp
Description: PGP signature

Reply via email to