CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
switch statements

 



vassago
Novice

Dec 2, 2008, 3:58 PM

Post #1 of 4 (377 views)
switch statements Can't Post

is there a way in perl to match multiple cases?
for example:
case (01, 02,04,05,06,07,08,09,10,11,12,13,15,25){
......
}

i also tried:
case [01,02,04,05,06,07,08,09,10,11,12,13,15,25]{
......
}
but i get an error 'illegal octal digit '8'' same for '9'. the info i'm parsing has a 2 digit site number, so that's why it is '08' and '09'

thanks.


KevinR
Veteran


Dec 2, 2008, 4:31 PM

Post #2 of 4 (376 views)
Re: [vassago] switch statements [In reply to] Can't Post

Perl has no case function. Are you using the Switch module?
-------------------------------------------------


vassago
Novice

Dec 2, 2008, 4:34 PM

Post #3 of 4 (374 views)
Re: [KevinR] switch statements [In reply to] Can't Post

i'm using Switch. yes.

i looked that far, and it looks like using [] is the correct syntax. i'm just stuck on the illegal octal digit now.


(This post was edited by vassago on Dec 2, 2008, 4:55 PM)


KevinR
Veteran


Dec 2, 2008, 4:55 PM

Post #4 of 4 (370 views)
Re: [vassago] switch statements [In reply to] Can't Post

Not that I ever use that module but I beleive it goes like this:


Code
switch ($var) { 
case (qw(01 02 04 05 06 07 08 09 10 11 12 13 15 25)) {
do something
}
}

-------------------------------------------------


(This post was edited by KevinR on Dec 2, 2008, 4:56 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives