Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: How would you shorten this regexp conditional?by japhy (Canon) |
on Jan 25, 2002 at 17:23 UTC ( [id://141491]=note: print w/replies, xml ) | Need Help?? |
I'd just use the ternary operator:
my $color = $white =~ /princepawn/ ? 'w' : 'b';
If I was feeling rowdy, I might do:
my $color = ('b','w')[$white =~ /princepawn/];
_____________________________________________________
In Section
Seekers of Perl Wisdom
|
|