develooper Front page | perl.beginners | Postings from February 2002

Re: Does Perl have "Case" Statements?

Thread Previous | Thread Next
John W. Krahn
February 28, 2002 13:54
Re: Does Perl have "Case" Statements?
Message ID:
Chris wrote:
> I have been looking in the Learning Perl book, and cannot find it.
> I am sure that it is just a terminology thing.
> In VB {Yeah the old VB again :P) I could do:
> Select Case $Junk
>      Case 1
>         Do Something
>      Case 2
>         Do Something
>      Case 3
>         Do Something
>      Case 4
>         Do Something
> End Select
> Does Perl have something similar to where I do not have to have one
> humongous IF statement?
> I have a file I have to read in, and there are 2 fields I have to look
> at.  In those two fields, one is a password, and I have to display
> the decrypted password to the admin.
> Reading the file is not hard.
> Getting the proper fields is not hard.
> But the password is based on something "a little different" so it isn't just
> pass the decrypt to it...  I have the workaround I was given to
> determine it, but that means that I have to read it and look
> for the matching string.
> Thus a Case Statement, IMHO, would be the best possible solution - with
> my current knowledge...

perldoc -q "How do I create a switch or case statement"

use Perl;

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About