[EMAIL PROTECTED] wrote:
How do I shorten this code:-

if $playercard1 = 10 or $playercard1 = "J" or $playercard1 = "Q" or $playercard1 = "K";

That code does not compile. Besides that it would not do what you think it would.

You probably want something like:

    if ( grep $_ eq $playercard1, qw/10 J Q K/ ) {
        # do something
    }

Please read about the grep() function in "perldoc -f grep", and about equality operators and the qw// operator in "perldoc perlop".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to