RPrinceton
Programmer
Hi,
I like using case structure instead of "If" statements because I think they are much more readable so when I learn any new language I always look to see if the language supports the "Case" construct. In perlsyn(1) I found the following "Case" i.e., "Switch" construct.
SWITCH:
{
$abc = 1, last SWITCH if /^abc/;
$def = 1, last SWITCH if /^def/;
$xyz = 1, last SWITCH if /^xyz/;
$nothing = 1;
}
In psuedo code I want to do the following:
Select Case $DBI::err
Case 0
...call successful
Case 1062
"Duplicate database key"
Case Else
"Any other errors"
End Select
How do I code the Perl equivalent?
Hope this is clear.
Please advise.
Thanks in advance.
Regards,
Randall Princeton
I like using case structure instead of "If" statements because I think they are much more readable so when I learn any new language I always look to see if the language supports the "Case" construct. In perlsyn(1) I found the following "Case" i.e., "Switch" construct.
SWITCH:
{
$abc = 1, last SWITCH if /^abc/;
$def = 1, last SWITCH if /^def/;
$xyz = 1, last SWITCH if /^xyz/;
$nothing = 1;
}
In psuedo code I want to do the following:
Select Case $DBI::err
Case 0
...call successful
Case 1062
"Duplicate database key"
Case Else
"Any other errors"
End Select
How do I code the Perl equivalent?
Hope this is clear.
Please advise.
Thanks in advance.
Regards,
Randall Princeton