On Mon, 2002-04-22 at 06:52, walter valenti wrote:
> Hi,
> 
> there is in Perl a statement "case" like in "C" or in "Pascal" ???
> 
>     Walter

Damian Conway has written a module to implement a switch for Perl as a
proof of concept for Perl 6.  You can install it by saying 

perl -MCPAN -e "install Switch"

<snip href="perldoc Switch">
use Switch;

switch ($val) {

        case 1          { print "number 1" }
        case "a"        { print "string a" }
                       case [1..10,42] { print "number in list" }
                       case (@array)   { print "number in list" }
                       case /\w+/      { print "pattern" }
                       case qr/\w+/    { print "pattern" }
                       case (%hash)    { print "entry in hash" }
                       case (\%hash)   { print "entry in hash" }
                       case (\&sub)    { print "arg to subroutine" }
           else            { print "previous case not true" }
   }
</snip>


 
-- 
Today is Pungenday the 40th day of Discord in the YOLD 3168
Or is it?

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to