On Tue, Mar 11, 2008 at 11:23 AM, <[EMAIL PROTECTED]> wrote: > How do I shorten this code:- > > if $playercard1 = 10 or $playercard1 = "J" or $playercard1 = "Q" or > $playercard1 = "K";
Here's my version of a program that does the same thing as yours. It's got some advantages over yours, but it's not really shorter: #!/usr/bin/perl use strict; use warnings; print qq{syntax error at - line 1, near "if \$playercard1 "\n}; print qq{Execution of your_broken_code aborted }; print qq{due to compilation errors.\n}; You can optimize your code for many things; for speed, for code size, for understandability. But making it work right in the first place is more important than any of those other things. ObPerl: my %tenjqk = map +($_,1), qw{10 J Q K}; print "gotcha\n" if $tenjqk{$playercard1}; Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/