: I think what I need is something called a case. but I can't find the syntax
: anywhere.

Perl doesn't have an official case (that is, switch) statement, but
there is a Switch.pm module available on CPAN. Here's the synopsis from
its manpage:

        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" }
        }

It's a very powerful tool (though I found that use'ing it introduces a
start-up latency which could be bad for straight CGI scripts).

There are several other ways to do things like this (otherwise it
wouldn't be Perl;) See the Camel, 2nd ed pg 104 or 3rd ed pg 124 for
more about this.

-- tdk

Reply via email to