Rodrick Brown wrote:
On Tue, Mar 11, 2008 at 2:46 PM, Rodrick Brown <[EMAIL PROTECTED]> wrote:
On Tue, Mar 11, 2008 at 2:23 PM,  <[EMAIL PROTECTED]> wrote:

How do I shorten this code:-

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

print "Player has high card\n" if ( $playercard1 =~ /10|J|Q|K/ )

Opps I ment to type the following instead.

print "Player has high card\n" if ( $playercard1 =~ /^(10|J|Q|K)$/ )

Or even better:

print "Player has high card\n" if $playercard1 =~ /\A(?:10|[JQK])\z/;



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to